@engenty/wizards-runtime 0.0.0-stage → 0.7.5
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/LICENSE +110 -0
- package/README.md +214 -2
- package/apps/runtime/dist/agents/architect.js +444 -0
- package/apps/runtime/dist/agents/studio-assistant.js +883 -0
- package/apps/runtime/dist/agents/subscription.js +207 -0
- package/apps/runtime/dist/agents/thought.js +21 -0
- package/apps/runtime/dist/agents/website.js +480 -0
- package/apps/runtime/dist/app.js +359 -0
- package/apps/runtime/dist/apple/wizards-apple +0 -0
- package/apps/runtime/dist/assistant/browser.js +26 -0
- package/apps/runtime/dist/assistant/docs.js +158 -0
- package/apps/runtime/dist/assistant/knows.js +353 -0
- package/apps/runtime/dist/assistant/primer.js +26 -0
- package/apps/runtime/dist/assistant/runs.js +24 -0
- package/apps/runtime/dist/auth/account.js +175 -0
- package/apps/runtime/dist/auth/device.js +112 -0
- package/apps/runtime/dist/auth/index.js +358 -0
- package/apps/runtime/dist/auth/keys.js +55 -0
- package/apps/runtime/dist/auth/local-ticket.js +26 -0
- package/apps/runtime/dist/authoring/example.js +74 -0
- package/apps/runtime/dist/authoring/guide.js +433 -0
- package/apps/runtime/dist/authoring/ops.js +117 -0
- package/apps/runtime/dist/browser/fast/action-space.js +160 -0
- package/apps/runtime/dist/browser/fast/classifier.js +91 -0
- package/apps/runtime/dist/browser/fast/decide.js +171 -0
- package/apps/runtime/dist/browser/fast/driver.js +141 -0
- package/apps/runtime/dist/browser/fast/instructions.js +33 -0
- package/apps/runtime/dist/browser/fast/run.js +249 -0
- package/apps/runtime/dist/browser/fast/span-picker.js +153 -0
- package/apps/runtime/dist/browser/fast/text-helper.js +178 -0
- package/apps/runtime/dist/browser/snapshot.js +335 -0
- package/apps/runtime/dist/cli/account.js +385 -0
- package/apps/runtime/dist/cli/autostart.js +182 -0
- package/apps/runtime/dist/cli/autoupdate.js +221 -0
- package/apps/runtime/dist/cli/clients.js +44 -0
- package/apps/runtime/dist/cli/connect.js +540 -0
- package/apps/runtime/dist/cli/environment.js +93 -0
- package/apps/runtime/dist/cli/exec.js +45 -0
- package/apps/runtime/dist/cli/features.js +50 -0
- package/apps/runtime/dist/cli/home.js +88 -0
- package/apps/runtime/dist/cli/install-env.js +33 -0
- package/apps/runtime/dist/cli/machine.js +107 -0
- package/apps/runtime/dist/cli/main.js +222 -0
- package/apps/runtime/dist/cli/mcp.js +136 -0
- package/apps/runtime/dist/cli/menu.js +202 -0
- package/apps/runtime/dist/cli/processes.js +72 -0
- package/apps/runtime/dist/cli/report.js +66 -0
- package/apps/runtime/dist/cli/setup.js +335 -0
- package/apps/runtime/dist/cli/start.js +276 -0
- package/apps/runtime/dist/cli/status.js +203 -0
- package/apps/runtime/dist/cli/ui.js +59 -0
- package/apps/runtime/dist/cli/uninstall-main.js +20 -0
- package/apps/runtime/dist/cli/uninstall.js +231 -0
- package/apps/runtime/dist/cli/update.js +86 -0
- package/apps/runtime/dist/cli/validate.js +75 -0
- package/apps/runtime/dist/cli/versions.js +123 -0
- package/apps/runtime/dist/connectors/builtin.js +86 -0
- package/apps/runtime/dist/connectors/external.js +409 -0
- package/apps/runtime/dist/connectors/gmail.js +107 -0
- package/apps/runtime/dist/connectors/imap.js +261 -0
- package/apps/runtime/dist/connectors/index.js +325 -0
- package/apps/runtime/dist/connectors/mail.js +72 -0
- package/apps/runtime/dist/connectors/outlook.js +90 -0
- package/apps/runtime/dist/connectors/plugin-connections.js +343 -0
- package/apps/runtime/dist/connectors/via-account.js +65 -0
- package/apps/runtime/dist/credits/credits.js +100 -0
- package/apps/runtime/dist/credits/estimate.js +152 -0
- package/apps/runtime/dist/db/adopt.js +149 -0
- package/apps/runtime/dist/db/client.js +173 -0
- package/apps/runtime/dist/db/control-schema.js +133 -0
- package/apps/runtime/dist/db/migrations/control/0000_last_absorbing_man.sql +47 -0
- package/apps/runtime/dist/db/migrations/control/0001_gorgeous_nicolaos.sql +41 -0
- package/apps/runtime/dist/db/migrations/control/0002_secret_penance.sql +1 -0
- package/apps/runtime/dist/db/migrations/control/0003_nasty_mordo.sql +3 -0
- package/apps/runtime/dist/db/migrations/control/0004_breezy_eddie_brock.sql +6 -0
- package/apps/runtime/dist/db/migrations/control/0005_chilly_oracle.sql +1 -0
- package/apps/runtime/dist/db/migrations/control/0006_sleepy_mojo.sql +1 -0
- package/apps/runtime/dist/db/migrations/control/0007_common_the_hand.sql +15 -0
- package/apps/runtime/dist/db/migrations/control/0008_runner.sql +8 -0
- package/apps/runtime/dist/db/migrations/control/0009_plugin_claim.sql +9 -0
- package/apps/runtime/dist/db/migrations/control/0010_tan_snowbird.sql +6 -0
- package/apps/runtime/dist/db/migrations/control/meta/0000_snapshot.json +311 -0
- package/apps/runtime/dist/db/migrations/control/meta/0001_snapshot.json +599 -0
- package/apps/runtime/dist/db/migrations/control/meta/0002_snapshot.json +607 -0
- package/apps/runtime/dist/db/migrations/control/meta/0003_snapshot.json +311 -0
- package/apps/runtime/dist/db/migrations/control/meta/0004_snapshot.json +350 -0
- package/apps/runtime/dist/db/migrations/control/meta/0005_snapshot.json +358 -0
- package/apps/runtime/dist/db/migrations/control/meta/0006_snapshot.json +365 -0
- package/apps/runtime/dist/db/migrations/control/meta/0007_snapshot.json +460 -0
- package/apps/runtime/dist/db/migrations/control/meta/0008_snapshot.json +505 -0
- package/apps/runtime/dist/db/migrations/control/meta/0009_snapshot.json +561 -0
- package/apps/runtime/dist/db/migrations/control/meta/0010_snapshot.json +600 -0
- package/apps/runtime/dist/db/migrations/control/meta/_journal.json +83 -0
- package/apps/runtime/dist/db/migrations/tenant/0000_eminent_freak.sql +188 -0
- package/apps/runtime/dist/db/migrations/tenant/0001_salty_master_chief.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/0002_cloudy_firebird.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/0003_brown_warbound.sql +52 -0
- package/apps/runtime/dist/db/migrations/tenant/0004_romantic_nocturne.sql +6 -0
- package/apps/runtime/dist/db/migrations/tenant/0005_reflective_forgotten_one.sql +2 -0
- package/apps/runtime/dist/db/migrations/tenant/0006_hard_war_machine.sql +30 -0
- package/apps/runtime/dist/db/migrations/tenant/0007_space_data.sql +43 -0
- package/apps/runtime/dist/db/migrations/tenant/0008_run_event_note.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/0009_knowledge.sql +104 -0
- package/apps/runtime/dist/db/migrations/tenant/0010_plugin_connection.sql +15 -0
- package/apps/runtime/dist/db/migrations/tenant/0011_runners.sql +2 -0
- package/apps/runtime/dist/db/migrations/tenant/0012_assistant_chat.sql +40 -0
- package/apps/runtime/dist/db/migrations/tenant/0013_run_origin.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/0014_run_answer.sql +2 -0
- package/apps/runtime/dist/db/migrations/tenant/0015_device_calls.sql +13 -0
- package/apps/runtime/dist/db/migrations/tenant/0016_even_trish_tilby.sql +12 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0000_snapshot.json +1323 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0001_snapshot.json +1330 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0002_snapshot.json +1337 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0003_snapshot.json +1605 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0004_snapshot.json +1645 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0005_snapshot.json +1659 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0006_snapshot.json +1696 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0007_snapshot.json +2012 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0008_snapshot.json +2019 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0009_snapshot.json +2837 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0010_snapshot.json +2942 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0011_snapshot.json +2956 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0012_snapshot.json +3132 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0013_snapshot.json +3139 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0014_snapshot.json +3154 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0015_snapshot.json +3243 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0016_snapshot.json +3326 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +125 -0
- package/apps/runtime/dist/db/schema.js +602 -0
- package/apps/runtime/dist/debug.js +196 -0
- package/apps/runtime/dist/docs/dev/index.md +41 -0
- package/apps/runtime/dist/docs/dev/meta.json +7 -0
- package/apps/runtime/dist/docs/dev/plugins/connections.md +74 -0
- package/apps/runtime/dist/docs/dev/plugins/events.md +89 -0
- package/apps/runtime/dist/docs/dev/plugins/examples.md +101 -0
- package/apps/runtime/dist/docs/dev/plugins/index.md +78 -0
- package/apps/runtime/dist/docs/dev/plugins/layout.md +90 -0
- package/apps/runtime/dist/docs/dev/plugins/meta.json +28 -0
- package/apps/runtime/dist/docs/dev/plugins/quick-start.md +94 -0
- package/apps/runtime/dist/docs/dev/plugins/reference.md +348 -0
- package/apps/runtime/dist/docs/dev/plugins/reloading.md +76 -0
- package/apps/runtime/dist/docs/dev/plugins/routes.md +185 -0
- package/apps/runtime/dist/docs/dev/plugins/runners.md +230 -0
- package/apps/runtime/dist/docs/dev/plugins/server.md +281 -0
- package/apps/runtime/dist/docs/dev/plugins/shipping.md +79 -0
- package/apps/runtime/dist/docs/dev/plugins/space.md +297 -0
- package/apps/runtime/dist/docs/dev/plugins/starters.md +70 -0
- package/apps/runtime/dist/docs/dev/plugins/studio.md +363 -0
- package/apps/runtime/dist/docs/dev/plugins/styling.md +129 -0
- package/apps/runtime/dist/docs/dev/plugins/tables.md +104 -0
- package/apps/runtime/dist/docs/dev/plugins/tools.md +139 -0
- package/apps/runtime/dist/docs/dev/wizard-format.md +125 -0
- package/apps/runtime/dist/docs/meta.json +3 -0
- package/apps/runtime/dist/docs/user/ai-apps.md +112 -0
- package/apps/runtime/dist/docs/user/assistant.md +77 -0
- package/apps/runtime/dist/docs/user/build-a-wizard.md +116 -0
- package/apps/runtime/dist/docs/user/command-line.md +83 -0
- package/apps/runtime/dist/docs/user/connectors.md +90 -0
- package/apps/runtime/dist/docs/user/create-account.md +52 -0
- package/apps/runtime/dist/docs/user/data.md +66 -0
- package/apps/runtime/dist/docs/user/first-start.md +60 -0
- package/apps/runtime/dist/docs/user/index.md +49 -0
- package/apps/runtime/dist/docs/user/install.md +123 -0
- package/apps/runtime/dist/docs/user/local-only.md +42 -0
- package/apps/runtime/dist/docs/user/meta.json +32 -0
- package/apps/runtime/dist/docs/user/models.md +156 -0
- package/apps/runtime/dist/docs/user/plugins.md +71 -0
- package/apps/runtime/dist/docs/user/run.md +98 -0
- package/apps/runtime/dist/docs/user/server.md +52 -0
- package/apps/runtime/dist/docs/user/space.md +126 -0
- package/apps/runtime/dist/docs/user/steps.md +220 -0
- package/apps/runtime/dist/docs/user/test-and-share.md +224 -0
- package/apps/runtime/dist/docs/user/troubleshooting.md +67 -0
- package/apps/runtime/dist/docs/user/wordpress.md +121 -0
- package/apps/runtime/dist/documents/parse.js +246 -0
- package/apps/runtime/dist/engenty/connections-external/build-connector.js +193 -0
- package/apps/runtime/dist/engenty/connections-external/errors.js +11 -0
- package/apps/runtime/dist/engenty/connections-external/import-service.js +270 -0
- package/apps/runtime/dist/engenty/connections-external/importer/classify.js +34 -0
- package/apps/runtime/dist/engenty/connections-external/importer/map-auth.js +185 -0
- package/apps/runtime/dist/engenty/connections-external/importer/normalize-mcp.js +63 -0
- package/apps/runtime/dist/engenty/connections-external/importer/normalize-openapi.js +130 -0
- package/apps/runtime/dist/engenty/connections-external/invoke/http-invoker.js +143 -0
- package/apps/runtime/dist/engenty/connections-external/invoke/mcp-client.js +143 -0
- package/apps/runtime/dist/engenty/connections-external/net/guarded-fetch.js +119 -0
- package/apps/runtime/dist/engenty/connections-external/oauth-dcr.js +88 -0
- package/apps/runtime/dist/engenty/connections-external/registry-client.js +336 -0
- package/apps/runtime/dist/engenty/connections-external/registry-source.js +82 -0
- package/apps/runtime/dist/engenty/connections-external/types.js +7 -0
- package/apps/runtime/dist/engenty/connections-github/connector.js +209 -0
- package/apps/runtime/dist/engenty/connections-google/connectors/calendar.js +381 -0
- package/apps/runtime/dist/engenty/connections-google/connectors/contacts.js +94 -0
- package/apps/runtime/dist/engenty/connections-google/connectors/drive.js +290 -0
- package/apps/runtime/dist/engenty/connections-google/connectors/gmail.js +567 -0
- package/apps/runtime/dist/engenty/connections-google/definitions.js +11 -0
- package/apps/runtime/dist/engenty/connections-google/shared.js +73 -0
- package/apps/runtime/dist/engenty/connections-hubspot/connector.js +140 -0
- package/apps/runtime/dist/engenty/connections-microsoft/action.js +17 -0
- package/apps/runtime/dist/engenty/connections-microsoft/graph.js +114 -0
- package/apps/runtime/dist/engenty/connections-microsoft/onedrive.js +286 -0
- package/apps/runtime/dist/engenty/connections-microsoft/outlook.js +492 -0
- package/apps/runtime/dist/engenty/connections-s3/s3.js +328 -0
- package/apps/runtime/dist/engenty/connections-sdk/files-capability.js +86 -0
- package/apps/runtime/dist/engenty/connections-sdk/oauth2.js +150 -0
- package/apps/runtime/dist/engenty/connections-sdk/registry.js +89 -0
- package/apps/runtime/dist/engenty/connections-sdk/storage-capability.js +84 -0
- package/apps/runtime/dist/engenty/connections-sdk/types.js +30 -0
- package/apps/runtime/dist/engenty/connections-slack/connector.js +360 -0
- package/apps/runtime/dist/engenty/csv-import/csv-matrix.js +178 -0
- package/apps/runtime/dist/engenty/csv-import/import-sources.js +87 -0
- package/apps/runtime/dist/engenty/csv-import/parse-csv.js +129 -0
- package/apps/runtime/dist/engenty/csv-import/serialize-csv.js +20 -0
- package/apps/runtime/dist/engenty/csv-import/types.js +1 -0
- package/apps/runtime/dist/engenty/csv-import/xlsx-workbook.js +159 -0
- package/apps/runtime/dist/engenty/doc-converter/interface.js +9 -0
- package/apps/runtime/dist/engenty/doc-converter/page-break.js +92 -0
- package/apps/runtime/dist/engenty/doc-converter/providers/local/index.js +72 -0
- package/apps/runtime/dist/engenty/document-scanner/schemas/classifier.js +30 -0
- package/apps/runtime/dist/engenty/document-scanner/schemas/index.js +4 -0
- package/apps/runtime/dist/engenty/document-scanner/schemas/invoice.js +73 -0
- package/apps/runtime/dist/engenty/document-scanner/schemas/receipt.js +63 -0
- package/apps/runtime/dist/engenty/document-scanner/schemas/shared.js +40 -0
- package/apps/runtime/dist/engenty/search-index/chunks.js +164 -0
- package/apps/runtime/dist/engenty/search-index/contracts.js +9 -0
- package/apps/runtime/dist/engenty/shims/connections-sdk.js +39 -0
- package/apps/runtime/dist/engenty/shims/plugin-sdk.js +1 -0
- package/apps/runtime/dist/engenty/shims/web-ingest.js +19 -0
- package/apps/runtime/dist/engenty/web-ingest/ssrf.js +277 -0
- package/apps/runtime/dist/engine/asks.js +82 -0
- package/apps/runtime/dist/engine/decide.js +82 -0
- package/apps/runtime/dist/engine/device.js +194 -0
- package/apps/runtime/dist/engine/events.js +128 -0
- package/apps/runtime/dist/engine/input.js +208 -0
- package/apps/runtime/dist/engine/owner.js +32 -0
- package/apps/runtime/dist/engine/prepare.js +90 -0
- package/apps/runtime/dist/engine/push.js +58 -0
- package/apps/runtime/dist/engine/requirements.js +355 -0
- package/apps/runtime/dist/engine/resources.js +198 -0
- package/apps/runtime/dist/engine/runner.js +970 -0
- package/apps/runtime/dist/engine/steps.js +1000 -0
- package/apps/runtime/dist/engine/surface.js +91 -0
- package/apps/runtime/dist/engine/template.js +240 -0
- package/apps/runtime/dist/engine/types.js +4 -0
- package/apps/runtime/dist/env.js +295 -0
- package/apps/runtime/dist/features.js +123 -0
- package/apps/runtime/dist/files/blobs.js +22 -0
- package/apps/runtime/dist/files/objects.js +86 -0
- package/apps/runtime/dist/files/storage.js +120 -0
- package/apps/runtime/dist/files/web-images.js +101 -0
- package/apps/runtime/dist/film/project.js +257 -0
- package/apps/runtime/dist/film/skills.js +91 -0
- package/apps/runtime/dist/film/sounds.js +122 -0
- package/apps/runtime/dist/film/step.js +289 -0
- package/apps/runtime/dist/film/tools.js +99 -0
- package/apps/runtime/dist/geocode.js +58 -0
- package/apps/runtime/dist/harness/antigravity.js +129 -0
- package/apps/runtime/dist/harness/apple.js +270 -0
- package/apps/runtime/dist/harness/claude.js +147 -0
- package/apps/runtime/dist/harness/codex.js +229 -0
- package/apps/runtime/dist/harness/cursor.js +93 -0
- package/apps/runtime/dist/harness/env.js +124 -0
- package/apps/runtime/dist/harness/index.js +95 -0
- package/apps/runtime/dist/harness/model.js +279 -0
- package/apps/runtime/dist/harness/prompt.js +121 -0
- package/apps/runtime/dist/harness/terminal.js +194 -0
- package/apps/runtime/dist/harness/types.js +7 -0
- package/apps/runtime/dist/index.js +113 -0
- package/apps/runtime/dist/limits.js +81 -0
- package/apps/runtime/dist/link-preview.js +60 -0
- package/apps/runtime/dist/log.js +106 -0
- package/apps/runtime/dist/manage.js +249 -0
- package/apps/runtime/dist/mcp/auth.js +161 -0
- package/apps/runtime/dist/mcp/bridge.js +59 -0
- package/apps/runtime/dist/mcp/flow-app.js +97 -0
- package/apps/runtime/dist/mcp/handler.js +54 -0
- package/apps/runtime/dist/mcp/scopes.js +14 -0
- package/apps/runtime/dist/mcp/seen.js +65 -0
- package/apps/runtime/dist/mcp/tools.js +572 -0
- package/apps/runtime/dist/media/conversation.js +167 -0
- package/apps/runtime/dist/media/ffmpeg.js +121 -0
- package/apps/runtime/dist/media/generate.js +120 -0
- package/apps/runtime/dist/media/marking.js +121 -0
- package/apps/runtime/dist/media/transcribe.js +198 -0
- package/apps/runtime/dist/model-errors.js +42 -0
- package/apps/runtime/dist/models.js +1164 -0
- package/apps/runtime/dist/plugin.js +61 -0
- package/apps/runtime/dist/plugins/channels.js +78 -0
- package/apps/runtime/dist/plugins/claims.js +56 -0
- package/apps/runtime/dist/plugins/discovery.js +155 -0
- package/apps/runtime/dist/plugins/events.js +63 -0
- package/apps/runtime/dist/plugins/jobs.js +64 -0
- package/apps/runtime/dist/plugins/loader.js +508 -0
- package/apps/runtime/dist/plugins/migrations.js +69 -0
- package/apps/runtime/dist/plugins/pro-keys.js +34 -0
- package/apps/runtime/dist/plugins/pro-state.js +83 -0
- package/apps/runtime/dist/plugins/pro.js +310 -0
- package/apps/runtime/dist/plugins/public.js +44 -0
- package/apps/runtime/dist/plugins/registry.js +122 -0
- package/apps/runtime/dist/plugins/runs.js +210 -0
- package/apps/runtime/dist/render/browser-path.js +54 -0
- package/apps/runtime/dist/render/chromium.js +98 -0
- package/apps/runtime/dist/render/convert.js +158 -0
- package/apps/runtime/dist/render/downloads.js +299 -0
- package/apps/runtime/dist/render/guard.js +25 -0
- package/apps/runtime/dist/render/shaped.js +137 -0
- package/apps/runtime/dist/routes/api.js +440 -0
- package/apps/runtime/dist/routes/debug.js +42 -0
- package/apps/runtime/dist/routes/delivery.js +90 -0
- package/apps/runtime/dist/routes/internal.js +81 -0
- package/apps/runtime/dist/routes/lang.js +25 -0
- package/apps/runtime/dist/routes/marketplace.js +43 -0
- package/apps/runtime/dist/routes/plugin-public.js +113 -0
- package/apps/runtime/dist/routes/plugins.js +212 -0
- package/apps/runtime/dist/routes/runs.js +1422 -0
- package/apps/runtime/dist/routes/studio.js +1629 -0
- package/apps/runtime/dist/routes/wizard-stream.js +30 -0
- package/apps/runtime/dist/running.js +39 -0
- package/apps/runtime/dist/sandbox/docker.js +75 -0
- package/apps/runtime/dist/sandbox/index.js +23 -0
- package/apps/runtime/dist/sandbox/types.js +1 -0
- package/apps/runtime/dist/secrets/crypto.js +28 -0
- package/apps/runtime/dist/secrets/signing.js +52 -0
- package/apps/runtime/dist/secrets/vault.js +59 -0
- package/apps/runtime/dist/services/access.js +88 -0
- package/apps/runtime/dist/services/api.js +248 -0
- package/apps/runtime/dist/services/architect.js +95 -0
- package/apps/runtime/dist/services/assistant-chats.js +311 -0
- package/apps/runtime/dist/services/brand.js +85 -0
- package/apps/runtime/dist/services/cloud.js +456 -0
- package/apps/runtime/dist/services/draft-events.js +27 -0
- package/apps/runtime/dist/services/engenty-shapes.js +71 -0
- package/apps/runtime/dist/services/errors.js +29 -0
- package/apps/runtime/dist/services/files.js +178 -0
- package/apps/runtime/dist/services/knowledge-model.js +559 -0
- package/apps/runtime/dist/services/knowledge.js +721 -0
- package/apps/runtime/dist/services/links.js +16 -0
- package/apps/runtime/dist/services/marketplace.js +492 -0
- package/apps/runtime/dist/services/onboarding.js +152 -0
- package/apps/runtime/dist/services/package-file.js +82 -0
- package/apps/runtime/dist/services/package.js +170 -0
- package/apps/runtime/dist/services/profile.js +51 -0
- package/apps/runtime/dist/services/project-files.js +439 -0
- package/apps/runtime/dist/services/project-index.js +707 -0
- package/apps/runtime/dist/services/projects.js +387 -0
- package/apps/runtime/dist/services/relevance.js +58 -0
- package/apps/runtime/dist/services/runners.js +178 -0
- package/apps/runtime/dist/services/runs.js +524 -0
- package/apps/runtime/dist/services/shares.js +130 -0
- package/apps/runtime/dist/services/site.js +270 -0
- package/apps/runtime/dist/services/space-categories.js +861 -0
- package/apps/runtime/dist/services/space-data.js +792 -0
- package/apps/runtime/dist/services/space-origin.js +207 -0
- package/apps/runtime/dist/services/spaces.js +656 -0
- package/apps/runtime/dist/services/translations.js +306 -0
- package/apps/runtime/dist/services/widgets.js +34 -0
- package/apps/runtime/dist/services/wizard-icon.js +157 -0
- package/apps/runtime/dist/services/wizards.js +420 -0
- package/apps/runtime/dist/settings.js +16 -0
- package/apps/runtime/dist/store/errors.js +4 -0
- package/apps/runtime/dist/store/index.js +299 -0
- package/apps/runtime/dist/store/shared-lists.js +123 -0
- package/apps/runtime/dist/tenants/control.js +238 -0
- package/apps/runtime/dist/tenants/tenant.js +26 -0
- package/apps/runtime/dist/texts.js +207 -0
- package/apps/runtime/dist/tools/browser.js +703 -0
- package/apps/runtime/dist/tools/connector.js +204 -0
- package/apps/runtime/dist/tools/index.js +291 -0
- package/apps/runtime/dist/tools/mail.js +104 -0
- package/apps/runtime/dist/tools/net-guard.js +170 -0
- package/apps/runtime/dist/tools/pages.js +81 -0
- package/apps/runtime/dist/tools/plugin.js +180 -0
- package/apps/runtime/dist/tools/project.js +154 -0
- package/apps/runtime/dist/tools/shared.js +69 -0
- package/apps/runtime/dist/tools/store.js +238 -0
- package/apps/runtime/dist/update.js +113 -0
- package/apps/runtime/dist/widgets/bundle.js +99 -0
- package/apps/runtime/dist/widgets/render.js +329 -0
- package/apps/runtime/dist/widgets/runtime.js +108 -0
- package/apps/runtime/dist/widgets/script.js +30 -0
- package/apps/runtime/dist/widgets/step.js +223 -0
- package/apps/web/dist/ai-labels/ai-black.svg +20 -0
- package/apps/web/dist/ai-labels/ai-generated-black.svg +31 -0
- package/apps/web/dist/ai-labels/ai-generated-white.svg +32 -0
- package/apps/web/dist/ai-labels/ai-modified-black.svg +30 -0
- package/apps/web/dist/ai-labels/ai-modified-white.svg +31 -0
- package/apps/web/dist/ai-labels/ai-white.svg +21 -0
- package/apps/web/dist/assets/AboutDialog-D4mvc-zu.js +1 -0
- package/apps/web/dist/assets/ChangelogDialog-DLqpJsF6.js +1 -0
- package/apps/web/dist/assets/ChatView-3laypRcE.js +10 -0
- package/apps/web/dist/assets/EditorPage-BalA5U2Y.js +3 -0
- package/apps/web/dist/assets/FlowPreview-CusP7ci9.js +1 -0
- package/apps/web/dist/assets/Harness-BrP-ENHg.css +1 -0
- package/apps/web/dist/assets/Harness-iYLtOLaK.js +16 -0
- package/apps/web/dist/assets/NewWizardChannels-CbwJ9A56.js +1 -0
- package/apps/web/dist/assets/NewWizardPage-BOBYiB9i.js +7 -0
- package/apps/web/dist/assets/OnboardingPage-CUwCiVIr.js +1 -0
- package/apps/web/dist/assets/ProjectPage-Bb16MdYG.js +1 -0
- package/apps/web/dist/assets/PublicRunner-BCt7Q6C-.js +1 -0
- package/apps/web/dist/assets/ReadOnly-kIHX2TEy.js +1 -0
- package/apps/web/dist/assets/RunDrawer-hZ9oeSXu.js +4 -0
- package/apps/web/dist/assets/RunnerView-DUS9fPmx.js +1 -0
- package/apps/web/dist/assets/SettingsPage-BzwR50fi.js +1 -0
- package/apps/web/dist/assets/SetupPage-gAp7rPxp.js +1 -0
- package/apps/web/dist/assets/SharePage-DqZWHva_.js +1 -0
- package/apps/web/dist/assets/changelog-DugmCNSf.js +1 -0
- package/apps/web/dist/assets/engenty-eXZ-EAwd.js +1 -0
- package/apps/web/dist/assets/esm-DXeMu8Lb.js +7 -0
- package/apps/web/dist/assets/fluffy-engenty-ClRou7yu.js +456 -0
- package/apps/web/dist/assets/index-AfUa8xKD.css +1 -0
- package/apps/web/dist/assets/index-C5Sm7tTR.js +14 -0
- package/apps/web/dist/assets/jsx-runtime-BNakU3Ej.js +1 -0
- package/apps/web/dist/assets/lock-R_CfU0Xo.js +1 -0
- package/apps/web/dist/assets/oss-credits-cZ9NUaLZ.js +1 -0
- package/apps/web/dist/assets/pdfmake-Cx9scTbD.js +228 -0
- package/apps/web/dist/assets/phone-CgrIS4_-.js +1 -0
- package/apps/web/dist/assets/preload-helper-CNEI7N0N.js +1 -0
- package/apps/web/dist/assets/qr-scanner-worker.min-CJaXo3yu.js +98 -0
- package/apps/web/dist/assets/qr-scanner.min-C_UI0gH-.js +1 -0
- package/apps/web/dist/assets/rolldown-runtime-hePW80VL.js +1 -0
- package/apps/web/dist/assets/settings-menu-2IMOOlLl.js +1 -0
- package/apps/web/dist/assets/ui-dzGvc3xk.js +137 -0
- package/apps/web/dist/assets/upload-BSuTilFF.js +1 -0
- package/apps/web/dist/assets/vfs_fonts-DllDSYt1.js +1 -0
- package/apps/web/dist/embed.js +266 -0
- package/apps/web/dist/favicon.svg +1 -0
- package/apps/web/dist/icons/apple-touch-icon.png +0 -0
- package/apps/web/dist/icons/icon-192.png +0 -0
- package/apps/web/dist/icons/icon-512.png +0 -0
- package/apps/web/dist/icons/icon-maskable-512.png +0 -0
- package/apps/web/dist/index.html +48 -0
- package/apps/web/dist/install.sh +577 -0
- package/apps/web/dist/manifest.webmanifest +21 -0
- package/apps/web/dist/mcp/flow.html +980 -0
- package/apps/web/dist/sw.js +15 -0
- package/bin/wizards.mjs +288 -0
- package/modules/README.md +15 -0
- package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +1150 -0
- package/node_modules/@engenty/wizards/dist/plugin/index.js +4 -0
- package/node_modules/@engenty/wizards/dist/plugin/studio.d.ts +322 -0
- package/node_modules/@engenty/wizards/dist/plugin/studio.js +4 -0
- package/node_modules/@engenty/wizards/dist/plugin/thread.d.ts +174 -0
- package/node_modules/@engenty/wizards/dist/plugin/thread.js +821 -0
- package/node_modules/@engenty/wizards/package.json +11 -0
- package/node_modules/@engenty-wizards/shared/dist/assistant.d.ts +174 -0
- package/node_modules/@engenty-wizards/shared/dist/assistant.js +65 -0
- package/node_modules/@engenty-wizards/shared/dist/changes.d.ts +22 -0
- package/node_modules/@engenty-wizards/shared/dist/changes.js +61 -0
- package/node_modules/@engenty-wizards/shared/dist/connectors.d.ts +77 -0
- package/node_modules/@engenty-wizards/shared/dist/connectors.js +2 -0
- package/node_modules/@engenty-wizards/shared/dist/decision.d.ts +76 -0
- package/node_modules/@engenty-wizards/shared/dist/decision.js +147 -0
- package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +2922 -0
- package/node_modules/@engenty-wizards/shared/dist/definition.js +1920 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-format.d.ts +5 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-format.js +132 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-value.d.ts +11 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-value.js +209 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns.d.ts +532 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns.js +217 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/index.d.ts +3 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/index.js +3 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-lexical.d.ts +14 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-lexical.js +166 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-rank.d.ts +33 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-rank.js +99 -0
- package/node_modules/@engenty-wizards/shared/dist/feature-flags.d.ts +78 -0
- package/node_modules/@engenty-wizards/shared/dist/feature-flags.js +70 -0
- package/node_modules/@engenty-wizards/shared/dist/features.d.ts +41 -0
- package/node_modules/@engenty-wizards/shared/dist/features.js +89 -0
- package/node_modules/@engenty-wizards/shared/dist/fit.d.ts +71 -0
- package/node_modules/@engenty-wizards/shared/dist/fit.js +382 -0
- package/node_modules/@engenty-wizards/shared/dist/json-schema.d.ts +14 -0
- package/node_modules/@engenty-wizards/shared/dist/json-schema.js +66 -0
- package/node_modules/@engenty-wizards/shared/dist/knowledge.d.ts +199 -0
- package/node_modules/@engenty-wizards/shared/dist/knowledge.js +68 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace-entry.d.ts +35 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace-entry.js +107 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace-search.d.ts +20 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace-search.js +136 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace.d.ts +227 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace.js +354 -0
- package/node_modules/@engenty-wizards/shared/dist/merge.d.ts +7 -0
- package/node_modules/@engenty-wizards/shared/dist/merge.js +40 -0
- package/node_modules/@engenty-wizards/shared/dist/numbers.d.ts +24 -0
- package/node_modules/@engenty-wizards/shared/dist/numbers.js +54 -0
- package/node_modules/@engenty-wizards/shared/dist/projects.d.ts +224 -0
- package/node_modules/@engenty-wizards/shared/dist/projects.js +319 -0
- package/node_modules/@engenty-wizards/shared/dist/providers.d.ts +101 -0
- package/node_modules/@engenty-wizards/shared/dist/providers.js +390 -0
- package/node_modules/@engenty-wizards/shared/dist/run.d.ts +680 -0
- package/node_modules/@engenty-wizards/shared/dist/run.js +620 -0
- package/node_modules/@engenty-wizards/shared/dist/runner-texts.d.ts +546 -0
- package/node_modules/@engenty-wizards/shared/dist/runner-texts.js +523 -0
- package/node_modules/@engenty-wizards/shared/dist/runners.d.ts +93 -0
- package/node_modules/@engenty-wizards/shared/dist/runners.js +146 -0
- package/node_modules/@engenty-wizards/shared/dist/shape.d.ts +102 -0
- package/node_modules/@engenty-wizards/shared/dist/shape.js +318 -0
- package/node_modules/@engenty-wizards/shared/dist/space-data.d.ts +89 -0
- package/node_modules/@engenty-wizards/shared/dist/space-data.js +47 -0
- package/node_modules/@engenty-wizards/shared/dist/store.d.ts +117 -0
- package/node_modules/@engenty-wizards/shared/dist/store.js +81 -0
- package/node_modules/@engenty-wizards/shared/dist/surface.d.ts +115 -0
- package/node_modules/@engenty-wizards/shared/dist/surface.js +442 -0
- package/node_modules/@engenty-wizards/shared/dist/texts.d.ts +45 -0
- package/node_modules/@engenty-wizards/shared/dist/texts.js +54 -0
- package/node_modules/@engenty-wizards/shared/dist/translation.d.ts +23 -0
- package/node_modules/@engenty-wizards/shared/dist/translation.js +154 -0
- package/node_modules/@engenty-wizards/shared/dist/wizard-package.d.ts +48 -0
- package/node_modules/@engenty-wizards/shared/dist/wizard-package.js +49 -0
- package/node_modules/@engenty-wizards/shared/dist/workspace.d.ts +16 -0
- package/node_modules/@engenty-wizards/shared/dist/workspace.js +51 -0
- package/node_modules/@engenty-wizards/shared/package.json +10 -0
- package/package.json +77 -4
- package/plugin/.claude-plugin/plugin.json +9 -0
- package/plugin/.mcp.json +8 -0
- package/plugin/commands/wizard.md +8 -0
- package/plugin/skills/build-wizard/SKILL.md +27 -0
- package/plugin/skills/use-wizard/SKILL.md +18 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { defaultFeatures, FEATURE_NAME, parseFeatures, resolveFeatures, } from "@engenty-wizards/shared/features";
|
|
2
|
+
import { declaredFeatures, featuresFile, fileFeatures, writeFeature } from "../features.js";
|
|
3
|
+
import { discoverPlugins } from "../plugins/discovery.js";
|
|
4
|
+
import { pluginDirs } from "../plugins/loader.js";
|
|
5
|
+
import { proModulesDir } from "../plugins/pro-state.js";
|
|
6
|
+
import { cmd, tilde } from "./ui.js";
|
|
7
|
+
/**
|
|
8
|
+
* `wizards features` — the feature switches of this install, from its `.features` file. Not in
|
|
9
|
+
* the help: for whoever works on a part before it is on for everyone.
|
|
10
|
+
*
|
|
11
|
+
* features what is on, and where that comes from
|
|
12
|
+
* features <name> on|off put a switch into the file
|
|
13
|
+
* features <name> default take it out again
|
|
14
|
+
*/
|
|
15
|
+
export function featuresCommand(args) {
|
|
16
|
+
const [name, value] = args;
|
|
17
|
+
const file = featuresFile();
|
|
18
|
+
if (!name) {
|
|
19
|
+
// The core's switches and those the plugins here declare, without loading them.
|
|
20
|
+
const found = discoverPlugins([...pluginDirs(), proModulesDir()]).found;
|
|
21
|
+
const declared = declaredFeatures(found);
|
|
22
|
+
const fromEnv = parseFeatures(process.env.FEATURES ?? "");
|
|
23
|
+
const fromFile = fileFeatures(file);
|
|
24
|
+
const all = resolveFeatures(defaultFeatures(declared), fromEnv, fromFile);
|
|
25
|
+
const names = [
|
|
26
|
+
...new Set([...Object.keys(declared), ...Object.keys(fromEnv), ...Object.keys(fromFile)]),
|
|
27
|
+
];
|
|
28
|
+
for (const n of names) {
|
|
29
|
+
const source = n in fromFile ? "file" : n in fromEnv ? "FEATURES" : "default";
|
|
30
|
+
const d = declared[n];
|
|
31
|
+
const kind = d ? d.kind : "?";
|
|
32
|
+
console.log(`${all[n] ? "on " : "off"} ${n.padEnd(28)} ${kind.padEnd(8)} ${source.padEnd(9)} ${d?.label ?? ""}`);
|
|
33
|
+
}
|
|
34
|
+
console.log(`\nFile: ${tilde(file)}\nWhile engenty wizards runs, account and team switches apply on top of these.`);
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
if (!FEATURE_NAME.test(name)) {
|
|
38
|
+
console.error(`“${name}” isn’t a valid switch name (e.g. teamPlans, contacts.leadScoring).`);
|
|
39
|
+
return 2;
|
|
40
|
+
}
|
|
41
|
+
if (value === "on" || value === "off" || value === "default") {
|
|
42
|
+
writeFeature(name, value === "default" ? null : value === "on", file);
|
|
43
|
+
console.log(value === "default"
|
|
44
|
+
? `${name} follows the default again (${tilde(file)}). engenty wizards picks this up straight away.`
|
|
45
|
+
: `${name} is ${value} on this computer (${tilde(file)}). engenty wizards picks this up straight away.`);
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
console.error(`Usage: ${cmd(`features ${name} on|off|default`)}`);
|
|
49
|
+
return 2;
|
|
50
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { dirname, join, resolve, sep } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
/**
|
|
6
|
+
* Where a local install lives: `~/.engenty/wizards`, inside the folder the engenty framework
|
|
7
|
+
* keeps its own install in. `ENGENTY_HOME` moves both.
|
|
8
|
+
*/
|
|
9
|
+
export function wizardsHome(env = process.env) {
|
|
10
|
+
const base = env.ENGENTY_HOME?.trim() || join(homedir(), ".engenty");
|
|
11
|
+
return join(resolve(base), "wizards");
|
|
12
|
+
}
|
|
13
|
+
export function layout(home = wizardsHome()) {
|
|
14
|
+
return {
|
|
15
|
+
home,
|
|
16
|
+
data: join(home, "data"),
|
|
17
|
+
logs: join(home, "logs"),
|
|
18
|
+
envFile: join(home, ".env"),
|
|
19
|
+
installFile: join(home, "install.json"),
|
|
20
|
+
runtime: join(home, "runtime"),
|
|
21
|
+
tools: join(home, "tools"),
|
|
22
|
+
clients: join(home, "clients"),
|
|
23
|
+
bin: join(home, "bin"),
|
|
24
|
+
plugins: join(home, "plugins"),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** The folder this code was installed to: it holds `apps/`, `plugin/` and package.json. */
|
|
28
|
+
export const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../../../..");
|
|
29
|
+
let running;
|
|
30
|
+
/**
|
|
31
|
+
* The version this process runs, read once: an update replaces package.json under a runtime that
|
|
32
|
+
* still runs the old code, and the studio reloads only when another version answers.
|
|
33
|
+
*/
|
|
34
|
+
export function packageVersion() {
|
|
35
|
+
if (running === undefined) {
|
|
36
|
+
try {
|
|
37
|
+
running =
|
|
38
|
+
JSON.parse(readFileSync(join(packageRoot, "package.json"), "utf8")).version ?? "0.0.0";
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
running = "0.0.0";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return running ?? "0.0.0";
|
|
45
|
+
}
|
|
46
|
+
/** How this copy got here: by install.sh into the home folder, or by npm/npx or a checkout. */
|
|
47
|
+
export function installedByScript(paths = layout()) {
|
|
48
|
+
try {
|
|
49
|
+
// Node names this file by its real path; the home folder may be reached through a link.
|
|
50
|
+
return packageRoot.startsWith(realpathSync(paths.runtime) + sep);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** This copy is a checkout of the repository, run with `pnpm wizards`. */
|
|
57
|
+
export function isCheckout() {
|
|
58
|
+
return existsSync(join(packageRoot, "pnpm-workspace.yaml"));
|
|
59
|
+
}
|
|
60
|
+
/** How this install is started, as the person types it. */
|
|
61
|
+
export const command = () => installedByScript() ? "wizards" : isCheckout() ? "pnpm wizards" : "npx wizards";
|
|
62
|
+
export function readInstallNote(paths = layout()) {
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(readFileSync(paths.installFile, "utf8"));
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export function writeInstallNote(note, paths = layout()) {
|
|
71
|
+
// A checkout or npx has no install folder until something writes into it.
|
|
72
|
+
mkdirSync(dirname(paths.installFile), { recursive: true });
|
|
73
|
+
writeFileSync(paths.installFile, `${JSON.stringify(note, null, 2)}\n`);
|
|
74
|
+
}
|
|
75
|
+
/** `KEY=value` lines of the install's `.env`, the way the runtime reads them. */
|
|
76
|
+
export function readEnvFile(file) {
|
|
77
|
+
const out = {};
|
|
78
|
+
if (!existsSync(file)) {
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
for (const line of readFileSync(file, "utf8").split("\n")) {
|
|
82
|
+
const match = line.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*)\s*$/);
|
|
83
|
+
if (match) {
|
|
84
|
+
out[match[1]] = match[2].replace(/^(['"])(.*)\1$/, "$2");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { mkdirSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { layout, readEnvFile } from "./home.js";
|
|
4
|
+
/**
|
|
5
|
+
* Imported first by the command: before the runtime's modules load, this process sees the
|
|
6
|
+
* install the way its runtime does. env.ts reads the process once, when it is first imported,
|
|
7
|
+
* and `.env` from the working directory; the runtime starts in the install's folder (start.ts)
|
|
8
|
+
* and so reads the install's `.env`, with its data folder beside it. The command goes there
|
|
9
|
+
* too — else `wizards account` or `wizards status` from another folder would open a `data/`
|
|
10
|
+
* of its own there, with a secret of its own, and a vault the runtime cannot read.
|
|
11
|
+
*
|
|
12
|
+
* What the terminal exports for other projects never reaches the runtime (environment.ts); a
|
|
13
|
+
* few keys that would make this process another runtime are taken from the install's `.env`
|
|
14
|
+
* alone. The rest the runtime inherits, so the terminal's word stands.
|
|
15
|
+
*/
|
|
16
|
+
const paths = layout();
|
|
17
|
+
const fileEnv = readEnvFile(paths.envFile);
|
|
18
|
+
/** The install's data folder, as start.ts hands it to the runtime: the terminal's word first. */
|
|
19
|
+
const given = process.env.DATA_DIR?.trim() || fileEnv.DATA_DIR?.trim();
|
|
20
|
+
process.env.DATA_DIR = given ? resolve(paths.home, given) : paths.data;
|
|
21
|
+
for (const key of ["MANAGE_URL", "APP_SECRET", "DATABASE_URL", "DATABASE_AUTH_TOKEN"]) {
|
|
22
|
+
process.env[key] = fileEnv[key] ?? "";
|
|
23
|
+
}
|
|
24
|
+
// Keys and the account's sign-in live in the Keychain on a Mac, as the runtime keeps them.
|
|
25
|
+
if (process.platform === "darwin" &&
|
|
26
|
+
process.env.SECRETS === undefined &&
|
|
27
|
+
fileEnv.SECRETS === undefined) {
|
|
28
|
+
process.env.SECRETS = "keychain";
|
|
29
|
+
}
|
|
30
|
+
/** Where the command was typed: `wizards validate ./my.wizard` means a path from there. */
|
|
31
|
+
export const startedIn = process.cwd();
|
|
32
|
+
mkdirSync(paths.home, { recursive: true });
|
|
33
|
+
process.chdir(paths.home);
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { promisify } from "node:util";
|
|
6
|
+
// The search for a browser is shared with env.ts, so the runtime uses the one the setup found.
|
|
7
|
+
import { findChrome, findOnPath } from "../render/browser-path.js";
|
|
8
|
+
import { runtimePath } from "./environment.js";
|
|
9
|
+
export { findChrome, findOnPath };
|
|
10
|
+
const run = promisify(execFile);
|
|
11
|
+
/** The AI clients the runtime can think with, in the order its own setup offers them. */
|
|
12
|
+
export const CLIENTS = [
|
|
13
|
+
{
|
|
14
|
+
id: "codex",
|
|
15
|
+
name: "Codex",
|
|
16
|
+
bin: "codex",
|
|
17
|
+
account: "ChatGPT",
|
|
18
|
+
install: { kind: "npm", pkg: "@openai/codex" },
|
|
19
|
+
app: "ChatGPT",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: "claude",
|
|
23
|
+
name: "Claude Code",
|
|
24
|
+
bin: "claude",
|
|
25
|
+
account: "Claude",
|
|
26
|
+
install: { kind: "script", url: "https://claude.ai/install.sh" },
|
|
27
|
+
app: "Claude",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "antigravity",
|
|
31
|
+
name: "Antigravity",
|
|
32
|
+
bin: "agy",
|
|
33
|
+
account: "Google AI",
|
|
34
|
+
install: { kind: "script", url: "https://antigravity.google/cli/install.sh" },
|
|
35
|
+
app: "Antigravity",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: "cursor",
|
|
39
|
+
name: "Cursor Agent",
|
|
40
|
+
bin: "cursor-agent",
|
|
41
|
+
account: "Cursor",
|
|
42
|
+
install: { kind: "script", url: "https://cursor.com/install" },
|
|
43
|
+
app: "Cursor",
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
const APP_ROOTS = ["/Applications", join(homedir(), "Applications")];
|
|
47
|
+
/** Whether `<name>.app` is in one of the Mac's Applications folders. */
|
|
48
|
+
export function macAppPresent(name, roots = APP_ROOTS) {
|
|
49
|
+
return roots.some((root) => existsSync(join(root, `${name}.app`)));
|
|
50
|
+
}
|
|
51
|
+
/** The client's desktop app, when it is on this Mac: its name, e.g. "Claude". */
|
|
52
|
+
export function vendorApp(client, roots = APP_ROOTS) {
|
|
53
|
+
if (process.platform !== "darwin" || !client.app) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return macAppPresent(client.app, roots) ? client.app : null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The client the setup suggests among those not installed: the one whose app is on this Mac —
|
|
60
|
+
* its subscription is most likely already paid for — else the first.
|
|
61
|
+
*/
|
|
62
|
+
export function suggestedClient(missing) {
|
|
63
|
+
return missing.find((state) => vendorApp(state.client)) ?? missing[0] ?? null;
|
|
64
|
+
}
|
|
65
|
+
/** The first file of that name on a PATH that may be run. */
|
|
66
|
+
/** What a command prints for `--version`: its last word that looks like one. */
|
|
67
|
+
async function versionOf(file, path) {
|
|
68
|
+
try {
|
|
69
|
+
const { stdout } = await run(file, ["--version"], {
|
|
70
|
+
timeout: 10_000,
|
|
71
|
+
env: { ...process.env, PATH: path, TERM: "dumb" },
|
|
72
|
+
});
|
|
73
|
+
const line = stdout.trim().split("\n").pop()?.trim() ?? "";
|
|
74
|
+
return line.match(/\d+\.\d+[\w.+-]*/)?.[0] ?? (line || null);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export async function detectClients(paths) {
|
|
81
|
+
const path = runtimePath(paths, process.env);
|
|
82
|
+
return Promise.all(CLIENTS.map(async (client) => {
|
|
83
|
+
const file = findOnPath(client.bin, path);
|
|
84
|
+
// A file that does not answer `--version` is not a client we can run.
|
|
85
|
+
const version = file ? await versionOf(file, path) : null;
|
|
86
|
+
return { client, path: version ? file : null, version };
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
export async function findFfmpeg(env = process.env) {
|
|
90
|
+
const path = env.PATH ?? "";
|
|
91
|
+
const file = env.FFMPEG_PATH || findOnPath("ffmpeg", path);
|
|
92
|
+
if (!file) {
|
|
93
|
+
return { path: null, version: null };
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const { stdout } = await run(file, ["-version"], { timeout: 10_000 });
|
|
97
|
+
return { path: file, version: stdout.match(/ffmpeg version (\S+)/)?.[1] ?? null };
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return { path: null, version: null };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** Node 24.11 or newer: what the runtime is built for. */
|
|
104
|
+
export function nodeIsCurrent(version = process.versions.node) {
|
|
105
|
+
const [major, minor] = version.split(".").map(Number);
|
|
106
|
+
return major > 24 || (major === 24 && minor >= 11);
|
|
107
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import "./install-env.js";
|
|
2
|
+
import { accountCommand } from "./account.js";
|
|
3
|
+
import { apps, connectCommand } from "./connect.js";
|
|
4
|
+
import { featuresCommand } from "./features.js";
|
|
5
|
+
import { command, layout, packageVersion, readInstallNote } from "./home.js";
|
|
6
|
+
import { startedIn } from "./install-env.js";
|
|
7
|
+
import { CLIENTS, nodeIsCurrent } from "./machine.js";
|
|
8
|
+
import { mcp } from "./mcp.js";
|
|
9
|
+
import { menu } from "./menu.js";
|
|
10
|
+
import { logsCommand, reportCommand } from "./report.js";
|
|
11
|
+
import { setup } from "./setup.js";
|
|
12
|
+
import { open, start, studio } from "./start.js";
|
|
13
|
+
import { autostart, restart, status, stop } from "./status.js";
|
|
14
|
+
import { cmd, cyan, tilde } from "./ui.js";
|
|
15
|
+
import { autoUpdateCommand, update } from "./update.js";
|
|
16
|
+
import { validateCommand } from "./validate.js";
|
|
17
|
+
/** One line of the help: the name padded, then coloured, so the columns stay straight. */
|
|
18
|
+
const line = (name, what) => ` ${cyan(name.padEnd(command().length + 12))}${what}`;
|
|
19
|
+
const more = (what) => ` ${" ".repeat(command().length + 12)}${what}`;
|
|
20
|
+
const HELP = `engenty wizards ${packageVersion()}
|
|
21
|
+
engenty wizards runs the studio and your wizards on this computer. Below, “it” means engenty wizards.
|
|
22
|
+
|
|
23
|
+
Usage
|
|
24
|
+
${command()} [command] [options]
|
|
25
|
+
|
|
26
|
+
Commands
|
|
27
|
+
${line(command(), "show the status and a menu (start, stop, update…); runs the setup the first time")}
|
|
28
|
+
${more("(needs a terminal)")}
|
|
29
|
+
${line(`${command()} start`, "start it in this terminal and open the studio (Ctrl-C stops it)")}
|
|
30
|
+
${line(`${command()} studio`, "open the studio, starting it in the background if needed")}
|
|
31
|
+
${line(`${command()} setup`, "set up your engenty account, an AI client, ffmpeg and start at login")}
|
|
32
|
+
${line(`${command()} account`, "show your engenty account; add sign-in or sign-out to change it")}
|
|
33
|
+
${line(`${command()} open`, "sign this browser in to the running studio (--print: only print the link)")}
|
|
34
|
+
${line(`${command()} status`, "show what’s installed and running")}
|
|
35
|
+
${line(`${command()} doctor`, "show the status and check for problems")}
|
|
36
|
+
${line(`${command()} logs`, `print the last log lines (${command()} logs 500 for more)`)}
|
|
37
|
+
${line(`${command()} report`, "send the status, model settings and last log lines to your account for support")}
|
|
38
|
+
${line(`${command()} stop`, "stop it (your data is kept)")}
|
|
39
|
+
${line(`${command()} restart`, "restart it, e.g. to switch to a newly installed version")}
|
|
40
|
+
${line(`${command()} update`, "install the latest version")}
|
|
41
|
+
${line(`${command()} autoupdate`, "updates by themselves: add on or off (WIZARDS_DISABLE_AUTOUPDATE=1 is off too)")}
|
|
42
|
+
${more("(downloaded in the background, used from the next start; never during a run)")}
|
|
43
|
+
${line(`${command()} autostart`, "start it when you log in to this computer: add on or off")}
|
|
44
|
+
${more("(macOS: a LaunchAgent; Linux: a systemd user service)")}
|
|
45
|
+
${line(`${command()} connect`, "add your wizards to your AI apps: every app found, or the ones you name:")}
|
|
46
|
+
${more(apps(layout())
|
|
47
|
+
.map((app) => app.id)
|
|
48
|
+
.join(", "))}
|
|
49
|
+
${line(`${command()} disconnect`, "remove your wizards from those apps (same names)")}
|
|
50
|
+
${line(`${command()} mcp`, "run the MCP server over stdio (AI apps start this)")}
|
|
51
|
+
${line(`${command()} uninstall`, "take it off this computer: shows the plan, asks about your data (kept by default)")}
|
|
52
|
+
${more("--dry-run only shows it; --yes asks nothing and keeps your data; --yes --delete-data")}
|
|
53
|
+
${line(`${command()} validate`, "check wizards without the studio: .wizard files, unpacked packages, wizard JSON")}
|
|
54
|
+
${more("--json prints the issues as JSON. A space’s connectors and plugins are checked on import.")}
|
|
55
|
+
|
|
56
|
+
Options
|
|
57
|
+
--yes, -y don’t ask; skip everything optional
|
|
58
|
+
--local set up without an account; nothing leaves this computer
|
|
59
|
+
--client <name> install this AI client without asking: ${CLIENTS.map((c) => c.id).join(", ")}
|
|
60
|
+
--no-open start without opening the browser
|
|
61
|
+
--background, -s start in the background, detached from this terminal (${command()} stop stops it)
|
|
62
|
+
--version, -v print the version
|
|
63
|
+
--help, -h print this help
|
|
64
|
+
|
|
65
|
+
Everything lives in ${tilde(layout().home)} (ENGENTY_HOME moves it). Settings go in its .env file.
|
|
66
|
+
`;
|
|
67
|
+
/** After a mistake on the command line: one line, not the whole help. */
|
|
68
|
+
const SEE_HELP = `Run ${cmd("help")} to see every command.`;
|
|
69
|
+
function parse(argv) {
|
|
70
|
+
const args = {
|
|
71
|
+
command: "",
|
|
72
|
+
value: "",
|
|
73
|
+
apps: [],
|
|
74
|
+
paths: [],
|
|
75
|
+
json: false,
|
|
76
|
+
yes: false,
|
|
77
|
+
local: false,
|
|
78
|
+
open: true,
|
|
79
|
+
service: false,
|
|
80
|
+
print: false,
|
|
81
|
+
clients: [],
|
|
82
|
+
};
|
|
83
|
+
for (let i = 0; i < argv.length; i++) {
|
|
84
|
+
const arg = argv[i];
|
|
85
|
+
if (arg === "--yes" || arg === "-y") {
|
|
86
|
+
args.yes = true;
|
|
87
|
+
}
|
|
88
|
+
else if (arg === "--local") {
|
|
89
|
+
args.local = true;
|
|
90
|
+
}
|
|
91
|
+
else if (arg === "--no-open") {
|
|
92
|
+
args.open = false;
|
|
93
|
+
}
|
|
94
|
+
else if (arg === "--background" || arg === "--service" || arg === "-s") {
|
|
95
|
+
args.service = true;
|
|
96
|
+
}
|
|
97
|
+
else if (arg === "--print") {
|
|
98
|
+
args.print = true;
|
|
99
|
+
}
|
|
100
|
+
else if (arg === "--json") {
|
|
101
|
+
args.json = true;
|
|
102
|
+
}
|
|
103
|
+
else if (arg === "--client") {
|
|
104
|
+
const id = argv[++i];
|
|
105
|
+
if (!CLIENTS.some((client) => client.id === id)) {
|
|
106
|
+
return `--client takes one of these: ${CLIENTS.map((c) => c.id).join(", ")}.`;
|
|
107
|
+
}
|
|
108
|
+
args.clients.push(id);
|
|
109
|
+
}
|
|
110
|
+
else if (arg === "--help" || arg === "-h") {
|
|
111
|
+
args.command = "help";
|
|
112
|
+
}
|
|
113
|
+
else if (arg === "--version" || arg === "-v") {
|
|
114
|
+
args.command = "version";
|
|
115
|
+
}
|
|
116
|
+
else if (arg.startsWith("-")) {
|
|
117
|
+
return `Unknown option ${arg}.`;
|
|
118
|
+
}
|
|
119
|
+
else if (["autostart", "autoupdate", "logs", "account"].includes(args.command) &&
|
|
120
|
+
!args.value) {
|
|
121
|
+
args.value = arg;
|
|
122
|
+
}
|
|
123
|
+
else if (["connect", "disconnect", "features"].includes(args.command)) {
|
|
124
|
+
args.apps.push(arg);
|
|
125
|
+
}
|
|
126
|
+
else if (args.command === "validate") {
|
|
127
|
+
args.paths.push(arg);
|
|
128
|
+
}
|
|
129
|
+
else if (args.command) {
|
|
130
|
+
return `Unexpected argument “${arg}”.`;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
args.command = arg;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return args;
|
|
137
|
+
}
|
|
138
|
+
async function main(argv) {
|
|
139
|
+
const args = parse(argv);
|
|
140
|
+
if (typeof args === "string") {
|
|
141
|
+
console.error(`${args} ${SEE_HELP}`);
|
|
142
|
+
return 2;
|
|
143
|
+
}
|
|
144
|
+
const paths = layout();
|
|
145
|
+
const setupOptions = { yes: args.yes, clients: args.clients, local: args.local };
|
|
146
|
+
if (!args.command) {
|
|
147
|
+
// Without a command: the menu, which needs a terminal. Starting is \`start\`.
|
|
148
|
+
if (args.service || !args.open || args.print) {
|
|
149
|
+
console.error(`Those options belong to start: ${cmd(`start ${argv.join(" ")}`)}`);
|
|
150
|
+
return 2;
|
|
151
|
+
}
|
|
152
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
153
|
+
console.error(`The menu needs a terminal. To start engenty wizards: ${cmd("start")}\n\n${HELP}`);
|
|
154
|
+
return 2;
|
|
155
|
+
}
|
|
156
|
+
return menu(paths, setupOptions, HELP);
|
|
157
|
+
}
|
|
158
|
+
switch (args.command) {
|
|
159
|
+
case "help":
|
|
160
|
+
console.log(HELP);
|
|
161
|
+
return 0;
|
|
162
|
+
case "version":
|
|
163
|
+
console.log(packageVersion());
|
|
164
|
+
return 0;
|
|
165
|
+
case "start": {
|
|
166
|
+
// The first start on a terminal begins with the setup.
|
|
167
|
+
const first = !readInstallNote(paths).setupAt;
|
|
168
|
+
if (first && !args.yes && process.stdin.isTTY && process.stdout.isTTY) {
|
|
169
|
+
// You asked to start it: once the setup is done, it starts.
|
|
170
|
+
if (!(await setup(paths, { ...setupOptions, next: "start" }))) {
|
|
171
|
+
return 130;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return start(paths, { open: args.open, background: args.service });
|
|
175
|
+
}
|
|
176
|
+
case "setup":
|
|
177
|
+
return (await setup(paths, setupOptions)) ? 0 : 130;
|
|
178
|
+
case "studio":
|
|
179
|
+
return studio(paths);
|
|
180
|
+
case "open":
|
|
181
|
+
return open(paths, args.print);
|
|
182
|
+
case "status":
|
|
183
|
+
return status(paths, false);
|
|
184
|
+
case "doctor":
|
|
185
|
+
return status(paths, true);
|
|
186
|
+
case "logs":
|
|
187
|
+
return logsCommand(paths, args.value);
|
|
188
|
+
case "report":
|
|
189
|
+
return reportCommand(paths);
|
|
190
|
+
case "stop":
|
|
191
|
+
return stop(paths);
|
|
192
|
+
case "restart":
|
|
193
|
+
return restart(paths);
|
|
194
|
+
case "update":
|
|
195
|
+
return update(paths);
|
|
196
|
+
case "autostart":
|
|
197
|
+
return autostart(paths, args.value);
|
|
198
|
+
case "autoupdate":
|
|
199
|
+
return autoUpdateCommand(paths, args.value);
|
|
200
|
+
case "account":
|
|
201
|
+
return accountCommand(paths, args.value, { yes: args.yes });
|
|
202
|
+
case "connect":
|
|
203
|
+
case "disconnect":
|
|
204
|
+
return connectCommand(paths, args.apps, args.command === "disconnect");
|
|
205
|
+
case "mcp":
|
|
206
|
+
return mcp(paths);
|
|
207
|
+
case "features":
|
|
208
|
+
return featuresCommand(args.apps);
|
|
209
|
+
case "validate":
|
|
210
|
+
// The paths are the person's, from where they typed the command (install-env.ts).
|
|
211
|
+
process.chdir(startedIn);
|
|
212
|
+
return validateCommand(args.paths, args.json);
|
|
213
|
+
default:
|
|
214
|
+
console.error(`Unknown command “${args.command}”. ${SEE_HELP}`);
|
|
215
|
+
return 2;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (!nodeIsCurrent()) {
|
|
219
|
+
console.error(`engenty wizards needs Node.js 24.11 or newer. This is ${process.version}.`);
|
|
220
|
+
process.exit(1);
|
|
221
|
+
}
|
|
222
|
+
process.exitCode = await main(process.argv.slice(2));
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { createInterface } from "node:readline";
|
|
3
|
+
import { LOCAL_CLIENT_HEADER, LOCAL_MCP_HEADER, mintLocalTicket } from "../auth/local-ticket.js";
|
|
4
|
+
import { readSecret, runningRuntime, settings, startInBackground } from "./start.js";
|
|
5
|
+
import { tilde } from "./ui.js";
|
|
6
|
+
/** The JSON-RPC messages of a response: a JSON body (one or a batch) or a server-sent stream. */
|
|
7
|
+
export function messagesOf(contentType, body) {
|
|
8
|
+
if (!body.trim()) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
if (contentType.includes("text/event-stream")) {
|
|
12
|
+
const out = [];
|
|
13
|
+
for (const event of body.split(/\r?\n\r?\n/)) {
|
|
14
|
+
const data = event
|
|
15
|
+
.split(/\r?\n/)
|
|
16
|
+
.filter((line) => line.startsWith("data:"))
|
|
17
|
+
.map((line) => line.slice(5).replace(/^ /, ""))
|
|
18
|
+
.join("\n");
|
|
19
|
+
if (data.trim()) {
|
|
20
|
+
out.push(JSON.parse(data));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
const parsed = JSON.parse(body);
|
|
26
|
+
return Array.isArray(parsed) ? parsed : [parsed];
|
|
27
|
+
}
|
|
28
|
+
export async function mcp(paths) {
|
|
29
|
+
const { dataDir } = settings(paths);
|
|
30
|
+
let running = null;
|
|
31
|
+
let clientName = "";
|
|
32
|
+
let protocolVersion = "";
|
|
33
|
+
const runtime = () => {
|
|
34
|
+
running ??= (async () => {
|
|
35
|
+
const found = await runningRuntime(dataDir);
|
|
36
|
+
if (found) {
|
|
37
|
+
return found;
|
|
38
|
+
}
|
|
39
|
+
process.stderr.write("engenty wizards isn’t running. Starting it…\n");
|
|
40
|
+
const started = await startInBackground(paths);
|
|
41
|
+
if (started) {
|
|
42
|
+
return started;
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`engenty wizards didn’t start. Its log is in ${tilde(join(paths.logs, "runtime.log"))}.`);
|
|
45
|
+
})();
|
|
46
|
+
running.catch(() => {
|
|
47
|
+
running = null;
|
|
48
|
+
});
|
|
49
|
+
return running;
|
|
50
|
+
};
|
|
51
|
+
const post = async (message) => {
|
|
52
|
+
const at = await runtime();
|
|
53
|
+
const secret = readSecret(paths);
|
|
54
|
+
if (!secret) {
|
|
55
|
+
throw new Error("No secret in the data folder yet. Start engenty wizards once first.");
|
|
56
|
+
}
|
|
57
|
+
const response = await fetch(`http://127.0.0.1:${at.port}/api/mcp`, {
|
|
58
|
+
method: "POST",
|
|
59
|
+
headers: {
|
|
60
|
+
"content-type": "application/json",
|
|
61
|
+
accept: "application/json, text/event-stream",
|
|
62
|
+
[LOCAL_MCP_HEADER]: mintLocalTicket(secret, Date.now(), "local-mcp"),
|
|
63
|
+
...(clientName ? { [LOCAL_CLIENT_HEADER]: clientName } : {}),
|
|
64
|
+
...(protocolVersion ? { "mcp-protocol-version": protocolVersion } : {}),
|
|
65
|
+
},
|
|
66
|
+
body: JSON.stringify(message),
|
|
67
|
+
});
|
|
68
|
+
const body = await response.text();
|
|
69
|
+
if (!response.ok && response.status !== 202) {
|
|
70
|
+
throw new Error(`engenty wizards responded with ${response.status}: ${body.slice(0, 300)}`);
|
|
71
|
+
}
|
|
72
|
+
return messagesOf(response.headers.get("content-type") ?? "", body);
|
|
73
|
+
};
|
|
74
|
+
const write = (message) => {
|
|
75
|
+
process.stdout.write(`${JSON.stringify(message)}\n`);
|
|
76
|
+
};
|
|
77
|
+
const handle = async (message) => {
|
|
78
|
+
if (message.method === "initialize") {
|
|
79
|
+
const info = message.params?.clientInfo;
|
|
80
|
+
clientName = info?.title || info?.name || "";
|
|
81
|
+
}
|
|
82
|
+
let answers;
|
|
83
|
+
try {
|
|
84
|
+
answers = await post(message);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
// The runtime went away (stopped, restarted on another port): once more, with a fresh look.
|
|
88
|
+
running = null;
|
|
89
|
+
try {
|
|
90
|
+
answers = await post(message);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
if (message.id !== undefined && message.method) {
|
|
94
|
+
write({
|
|
95
|
+
jsonrpc: "2.0",
|
|
96
|
+
id: message.id,
|
|
97
|
+
error: { code: -32603, message: error.message },
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
process.stderr.write(`${error.message}\n`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
for (const answer of answers) {
|
|
105
|
+
const version = answer.result?.protocolVersion;
|
|
106
|
+
if (message.method === "initialize" && typeof version === "string") {
|
|
107
|
+
protocolVersion = version;
|
|
108
|
+
}
|
|
109
|
+
write(answer);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const pending = new Set();
|
|
113
|
+
const lines = createInterface({ input: process.stdin, crlfDelay: Number.POSITIVE_INFINITY });
|
|
114
|
+
for await (const line of lines) {
|
|
115
|
+
if (!line.trim()) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
let message;
|
|
119
|
+
try {
|
|
120
|
+
message = JSON.parse(line);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
write({
|
|
124
|
+
jsonrpc: "2.0",
|
|
125
|
+
id: null,
|
|
126
|
+
error: { code: -32700, message: "Parse error" },
|
|
127
|
+
});
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
// Requests are answered as they finish: a long get_run never holds up the next call.
|
|
131
|
+
const job = handle(message).finally(() => pending.delete(job));
|
|
132
|
+
pending.add(job);
|
|
133
|
+
}
|
|
134
|
+
await Promise.all(pending);
|
|
135
|
+
return 0;
|
|
136
|
+
}
|