@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,270 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { encryptToken, getConnectorDefinition } from "../shims/connections-sdk.js";
|
|
3
|
+
import { ImportValidationError } from "./errors.js";
|
|
4
|
+
import { mapAuth } from "./importer/map-auth.js";
|
|
5
|
+
import { normalizeMcpServer } from "./importer/normalize-mcp.js";
|
|
6
|
+
import { MAX_SPEC_BYTES, normalizeOpenApiSpec, } from "./importer/normalize-openapi.js";
|
|
7
|
+
import { isUnauthorizedMcpError } from "./invoke/mcp-client.js";
|
|
8
|
+
import { createGuardedFetch, fetchTextBounded } from "./net/guarded-fetch.js";
|
|
9
|
+
import { resolveMcpTransport, } from "./registry-client.js";
|
|
10
|
+
/**
|
|
11
|
+
* Import/refresh pipeline shared by the admin routes: fetch source → apply the
|
|
12
|
+
* registry's spec overrides → normalize → map auth → assemble the stored
|
|
13
|
+
* record. Pure of DB and registry-transport concerns — the routes/plugin own
|
|
14
|
+
* persistence, registry lookups and (re-)registration.
|
|
15
|
+
*
|
|
16
|
+
* Every registry fact this pipeline reads is either applied or refuses the
|
|
17
|
+
* import. A surface that needs a URL variable, an environment-sourced header,
|
|
18
|
+
* or auth we cannot express never becomes a half-working connector.
|
|
19
|
+
*/
|
|
20
|
+
const SPEC_FETCH_TIMEOUT_MS = 30_000;
|
|
21
|
+
/** Operation/tool ids must satisfy core's strict snake_case tool-id contract. */
|
|
22
|
+
const TOOL_PREFIX_RE = /^[a-z][a-z0-9_]{1,30}$/u;
|
|
23
|
+
export function validateConnectorNaming(params) {
|
|
24
|
+
if (!/^[a-z][a-z0-9-]{1,59}$/u.test(params.id)) {
|
|
25
|
+
throw new ImportValidationError(`connector id "${params.id}" must be kebab-case (a-z, 0-9, -)`);
|
|
26
|
+
}
|
|
27
|
+
if (!TOOL_PREFIX_RE.test(params.toolPrefix)) {
|
|
28
|
+
throw new ImportValidationError(`tool prefix "${params.toolPrefix}" must be snake_case, start with a letter, and stay short`);
|
|
29
|
+
}
|
|
30
|
+
const existing = getConnectorDefinition(params.id, params.tenantId);
|
|
31
|
+
if (existing && existing.moduleId !== "connections-external") {
|
|
32
|
+
throw new ImportValidationError(`connector id "${params.id}" collides with built-in connector "${existing.name}"`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
// Registry surface → import decisions
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
/** Connector id suggested by a registry surface slug ("stripe-mcp-server"). */
|
|
39
|
+
export function connectorIdFromSlug(slug) {
|
|
40
|
+
return slug
|
|
41
|
+
.toLowerCase()
|
|
42
|
+
.replace(/[^a-z0-9]+/gu, "-")
|
|
43
|
+
.replace(/^[-0-9]+|-+$/gu, "")
|
|
44
|
+
.slice(0, 60);
|
|
45
|
+
}
|
|
46
|
+
/** Tool prefix suggested by a registry surface slug ("stripe_mcp_server"). */
|
|
47
|
+
export function toolPrefixFromSlug(slug) {
|
|
48
|
+
return slug
|
|
49
|
+
.toLowerCase()
|
|
50
|
+
.replace(/[^a-z0-9]+/gu, "_")
|
|
51
|
+
.replace(/^[_0-9]+|_+$/gu, "")
|
|
52
|
+
.slice(0, 30);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Static headers the API requires on every request. The registry also sources
|
|
56
|
+
* headers from the environment of the machine that talks to the API; those
|
|
57
|
+
* have no value we could store, so they block the import rather than being
|
|
58
|
+
* dropped on the floor.
|
|
59
|
+
*/
|
|
60
|
+
export function resolveRequiredHeaders(surface) {
|
|
61
|
+
const headers = [];
|
|
62
|
+
for (const header of surface.required_headers) {
|
|
63
|
+
const kind = header.source?.kind ?? "unknown";
|
|
64
|
+
if (kind !== "static") {
|
|
65
|
+
throw new ImportValidationError(`the registry requires header "${header.name}" from a ${kind} source — only static header values can be stored on an imported connector`);
|
|
66
|
+
}
|
|
67
|
+
const value = header.source?.value;
|
|
68
|
+
if (!value) {
|
|
69
|
+
throw new ImportValidationError(`the registry requires header "${header.name}" but publishes no value for it`);
|
|
70
|
+
}
|
|
71
|
+
headers.push({
|
|
72
|
+
description: header.description ?? null,
|
|
73
|
+
name: header.name,
|
|
74
|
+
value,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return headers;
|
|
78
|
+
}
|
|
79
|
+
/** Registry variables have no value at import time — reject, never guess. */
|
|
80
|
+
export function assertNoRegistryVariables(surface) {
|
|
81
|
+
if (surface.variables.length === 0) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const names = surface.variables.map((variable) => variable.name).join(", ");
|
|
85
|
+
throw new ImportValidationError(`this surface is templated on ${names} (${surface.variables
|
|
86
|
+
.map((variable) => variable.resolveFrom ?? variable.name)
|
|
87
|
+
.join("; ")}) — per-tenant URL variables are not supported; paste a resolved spec or endpoint URL instead`);
|
|
88
|
+
}
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// Fetch + normalize
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
export async function fetchSpecText(url, fetchImpl = createGuardedFetch()) {
|
|
93
|
+
return await fetchTextBounded({
|
|
94
|
+
fetchImpl,
|
|
95
|
+
headers: { accept: "application/json, application/yaml, text/yaml, */*" },
|
|
96
|
+
maxBytes: MAX_SPEC_BYTES,
|
|
97
|
+
signal: AbortSignal.timeout(SPEC_FETCH_TIMEOUT_MS),
|
|
98
|
+
url,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/** Registry surface whose MCP/API calls need a credential. */
|
|
102
|
+
export function surfaceRequiresAuth(surface) {
|
|
103
|
+
return surface?.auth.status === "required";
|
|
104
|
+
}
|
|
105
|
+
function emptyMcpNormalize() {
|
|
106
|
+
return {
|
|
107
|
+
actions: [],
|
|
108
|
+
applied_overrides: 0,
|
|
109
|
+
base_url: null,
|
|
110
|
+
description: null,
|
|
111
|
+
dropped_count: 0,
|
|
112
|
+
security_schemes: null,
|
|
113
|
+
skipped: [],
|
|
114
|
+
title: null,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export function deferredMcpPrepared(sourceUrl) {
|
|
118
|
+
return {
|
|
119
|
+
deferred_mcp_tools: true,
|
|
120
|
+
normalized: emptyMcpNormalize(),
|
|
121
|
+
spec_hash: createHash("sha256")
|
|
122
|
+
.update(`deferred-mcp:${sourceUrl}`)
|
|
123
|
+
.digest("hex"),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/** Fetch + normalize one source. openapi → spec text; mcp → live tools/list. */
|
|
127
|
+
export async function prepareSource(params) {
|
|
128
|
+
const fetchImpl = params.fetchImpl ?? createGuardedFetch();
|
|
129
|
+
const overrides = params.specOverrides ?? [];
|
|
130
|
+
if (params.sourceKind === "openapi") {
|
|
131
|
+
const specText = await fetchSpecText(params.sourceUrl, fetchImpl);
|
|
132
|
+
const normalized = await normalizeOpenApiSpec(specText, {
|
|
133
|
+
specOverrides: overrides,
|
|
134
|
+
});
|
|
135
|
+
return {
|
|
136
|
+
normalized,
|
|
137
|
+
// Overrides are part of what was imported: a changed patch must show up
|
|
138
|
+
// as a changed spec hash on refresh.
|
|
139
|
+
spec_hash: createHash("sha256")
|
|
140
|
+
.update(specText)
|
|
141
|
+
.update(JSON.stringify(overrides))
|
|
142
|
+
.digest("hex"),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
if (params.deferMcpTools) {
|
|
146
|
+
return deferredMcpPrepared(params.sourceUrl);
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
const normalized = await normalizeMcpServer({
|
|
150
|
+
endpoint: params.sourceUrl,
|
|
151
|
+
fetchImpl,
|
|
152
|
+
headers: {
|
|
153
|
+
...headersFromRequired(params.requiredHeaders ?? []),
|
|
154
|
+
...params.mcpHeaders,
|
|
155
|
+
},
|
|
156
|
+
transport: params.transport ?? null,
|
|
157
|
+
});
|
|
158
|
+
return {
|
|
159
|
+
normalized,
|
|
160
|
+
spec_hash: createHash("sha256")
|
|
161
|
+
.update(JSON.stringify(normalized.actions))
|
|
162
|
+
.digest("hex"),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
if ((params.deferOnUnauthorized ?? true) && isUnauthorizedMcpError(error)) {
|
|
167
|
+
return deferredMcpPrepared(params.sourceUrl);
|
|
168
|
+
}
|
|
169
|
+
throw error;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/** Stored required headers as a request header map. */
|
|
173
|
+
export function headersFromRequired(headers) {
|
|
174
|
+
const out = {};
|
|
175
|
+
for (const header of headers) {
|
|
176
|
+
out[header.name] = header.value;
|
|
177
|
+
}
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
export function assembleRecord(params) {
|
|
181
|
+
validateConnectorNaming({
|
|
182
|
+
id: params.id,
|
|
183
|
+
tenantId: params.tenantId,
|
|
184
|
+
toolPrefix: params.toolPrefix,
|
|
185
|
+
});
|
|
186
|
+
const { normalized } = params.prepared;
|
|
187
|
+
const warnings = [];
|
|
188
|
+
const surface = params.surface ?? null;
|
|
189
|
+
if (surface) {
|
|
190
|
+
assertNoRegistryVariables(surface);
|
|
191
|
+
}
|
|
192
|
+
const requiredHeaders = surface ? resolveRequiredHeaders(surface) : [];
|
|
193
|
+
const mapped = mapAuth({
|
|
194
|
+
discover: params.discover ?? null,
|
|
195
|
+
securitySchemes: normalized.security_schemes,
|
|
196
|
+
sourceKind: params.sourceKind,
|
|
197
|
+
surface,
|
|
198
|
+
});
|
|
199
|
+
if (!mapped.ok) {
|
|
200
|
+
throw new ImportValidationError(mapped.reason);
|
|
201
|
+
}
|
|
202
|
+
const auth = mapped.auth;
|
|
203
|
+
if (auth.kind === "oauth2" && !params.oauthClient) {
|
|
204
|
+
if (auth.dcr && auth.registration_endpoint) {
|
|
205
|
+
warnings.push("oauth2 client will be registered on first authenticate (dynamic client registration)");
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
warnings.push("oauth2 connector imported without client credentials — connects will fail until they are set");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const filter = params.actionFilter?.length
|
|
212
|
+
? new Set(params.actionFilter)
|
|
213
|
+
: null;
|
|
214
|
+
const actions = filter
|
|
215
|
+
? normalized.actions.filter((action) => filter.has(action.id))
|
|
216
|
+
: normalized.actions;
|
|
217
|
+
const deferredMcp = params.prepared.deferred_mcp_tools === true && params.sourceKind === "mcp";
|
|
218
|
+
if (actions.length === 0 && !deferredMcp) {
|
|
219
|
+
throw new ImportValidationError("no importable actions (empty spec, all filtered out, or all skipped)");
|
|
220
|
+
}
|
|
221
|
+
if (deferredMcp) {
|
|
222
|
+
warnings.push("tools load once an account is connected");
|
|
223
|
+
}
|
|
224
|
+
if (normalized.dropped_count > 0) {
|
|
225
|
+
warnings.push(`${normalized.dropped_count} operation(s) dropped by the per-connector cap`);
|
|
226
|
+
}
|
|
227
|
+
if (normalized.skipped.length > 0) {
|
|
228
|
+
warnings.push(`${normalized.skipped.length} operation(s) skipped: ${normalized.skipped
|
|
229
|
+
.slice(0, 5)
|
|
230
|
+
.map((s) => `${s.id} (${s.reason})`)
|
|
231
|
+
.join(", ")}${normalized.skipped.length > 5 ? ", …" : ""}`);
|
|
232
|
+
}
|
|
233
|
+
if (normalized.applied_overrides > 0) {
|
|
234
|
+
warnings.push(`${normalized.applied_overrides} registry spec override(s) applied before normalization`);
|
|
235
|
+
}
|
|
236
|
+
const baseUrl = params.baseUrlOverride ?? normalized.base_url ?? null;
|
|
237
|
+
if (params.sourceKind === "openapi" && !baseUrl) {
|
|
238
|
+
throw new ImportValidationError("spec declares no server URL — provide base_url explicitly");
|
|
239
|
+
}
|
|
240
|
+
const record = {
|
|
241
|
+
actions,
|
|
242
|
+
auth_config: auth,
|
|
243
|
+
base_url: baseUrl,
|
|
244
|
+
client_id_enc: params.oauthClient
|
|
245
|
+
? encryptToken(params.oauthClient.clientId)
|
|
246
|
+
: null,
|
|
247
|
+
client_secret_enc: params.oauthClient
|
|
248
|
+
? encryptToken(params.oauthClient.clientSecret)
|
|
249
|
+
: null,
|
|
250
|
+
domain: params.domain,
|
|
251
|
+
id: params.id,
|
|
252
|
+
imported_at: new Date().toISOString(),
|
|
253
|
+
imported_by: params.importedBy,
|
|
254
|
+
mcp_transport: params.sourceKind === "mcp"
|
|
255
|
+
? ((surface ? resolveMcpTransport(surface) : null) ?? "streamable-http")
|
|
256
|
+
: null,
|
|
257
|
+
name: params.name ?? normalized.title ?? surface?.name ?? params.domain,
|
|
258
|
+
refreshed_at: null,
|
|
259
|
+
registry_snapshot: params.rawDiscover ?? null,
|
|
260
|
+
registry_surface_slug: surface?.slug ?? null,
|
|
261
|
+
required_headers: requiredHeaders,
|
|
262
|
+
source_kind: params.sourceKind,
|
|
263
|
+
source_url: params.sourceUrl,
|
|
264
|
+
spec_hash: params.prepared.spec_hash,
|
|
265
|
+
status: "enabled",
|
|
266
|
+
tenant_id: params.tenantId,
|
|
267
|
+
tool_prefix: params.toolPrefix,
|
|
268
|
+
};
|
|
269
|
+
return { record, warnings };
|
|
270
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map an HTTP method (plus path hints) onto the connections-framework action
|
|
3
|
+
* groups. Groups drive default policy (read→allow, write/destructive→ask) and
|
|
4
|
+
* the approval contract, so lean conservative: anything ambiguous is `write`,
|
|
5
|
+
* clearly irreversible verbs are `destructive`.
|
|
6
|
+
*/
|
|
7
|
+
const DESTRUCTIVE_PATH_HINT = /\b(delete|remove|destroy|purge|revoke|cancel|terminate)\b/iu;
|
|
8
|
+
export function classifyHttpOperation(method, pathTemplate) {
|
|
9
|
+
const m = method.toLowerCase();
|
|
10
|
+
if (m === "get" || m === "head" || m === "options") {
|
|
11
|
+
return "read";
|
|
12
|
+
}
|
|
13
|
+
if (m === "delete") {
|
|
14
|
+
return "destructive";
|
|
15
|
+
}
|
|
16
|
+
if (DESTRUCTIVE_PATH_HINT.test(pathTemplate)) {
|
|
17
|
+
return "destructive";
|
|
18
|
+
}
|
|
19
|
+
return "write";
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* MCP tool annotations → classification. `readOnlyHint` is trusted for reads;
|
|
23
|
+
* `destructiveHint` for destructive; everything else defaults to `write`
|
|
24
|
+
* (server-provided hints are advisory, so no hint never yields `read`).
|
|
25
|
+
*/
|
|
26
|
+
export function classifyMcpTool(annotations) {
|
|
27
|
+
if (annotations.readOnlyHint === true) {
|
|
28
|
+
return "read";
|
|
29
|
+
}
|
|
30
|
+
if (annotations.destructiveHint === true) {
|
|
31
|
+
return "destructive";
|
|
32
|
+
}
|
|
33
|
+
return "write";
|
|
34
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { discoverOAuthFacts, } from "../registry-client.js";
|
|
2
|
+
/** Map an OpenAPI 3.x securitySchemes object (spec wins over registry facts). */
|
|
3
|
+
export function mapAuthFromSecuritySchemes(schemes) {
|
|
4
|
+
const entries = Object.entries(schemes);
|
|
5
|
+
// Prefer a static API key / bearer when the spec also advertises OAuth —
|
|
6
|
+
// personal access tokens work without an admin-registered developer app.
|
|
7
|
+
// Figma REST is the canonical case (PersonalAccessToken + OAuth2).
|
|
8
|
+
const bearer = entries.find(([, s]) => s.type === "http" && s.scheme?.toLowerCase() === "bearer");
|
|
9
|
+
if (bearer) {
|
|
10
|
+
return {
|
|
11
|
+
fields: [
|
|
12
|
+
{ key: "api_token", label: "API token", required: true, secret: true },
|
|
13
|
+
],
|
|
14
|
+
kind: "api_key",
|
|
15
|
+
placement: {
|
|
16
|
+
in: "header",
|
|
17
|
+
name: "Authorization",
|
|
18
|
+
value_template: "Bearer {{api_token}}",
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const apiKey = entries.find(([, s]) => s.type === "apiKey" && (s.in === "header" || s.in === "query"));
|
|
23
|
+
if (apiKey) {
|
|
24
|
+
const scheme = apiKey[1];
|
|
25
|
+
return {
|
|
26
|
+
fields: [
|
|
27
|
+
{ key: "api_key", label: "API key", required: true, secret: true },
|
|
28
|
+
],
|
|
29
|
+
kind: "api_key",
|
|
30
|
+
placement: {
|
|
31
|
+
in: scheme.in === "query" ? "query" : "header",
|
|
32
|
+
name: scheme.name ?? "X-API-Key",
|
|
33
|
+
value_template: "{{api_key}}",
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const oauth = entries.find(([, s]) => s.type === "oauth2" && s.flows?.authorizationCode);
|
|
38
|
+
if (oauth) {
|
|
39
|
+
const flow = oauth[1].flows?.authorizationCode;
|
|
40
|
+
if (flow?.authorizationUrl && flow.tokenUrl) {
|
|
41
|
+
return {
|
|
42
|
+
auth_url: flow.authorizationUrl,
|
|
43
|
+
kind: "oauth2",
|
|
44
|
+
scopes: Object.keys(flow.scopes ?? {}),
|
|
45
|
+
token_url: flow.tokenUrl,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
/** Fallback: map the domain's discovered OAuth facts. */
|
|
52
|
+
export function mapAuthFromRegistry(discover) {
|
|
53
|
+
const oauth = discoverOAuthFacts(discover);
|
|
54
|
+
if (oauth?.authorizationEndpoint &&
|
|
55
|
+
oauth.tokenEndpoint &&
|
|
56
|
+
(oauth.grantTypes.length === 0 ||
|
|
57
|
+
oauth.grantTypes.includes("authorization_code"))) {
|
|
58
|
+
const dcr = oauth.dcr === true && Boolean(oauth.registrationEndpoint?.trim());
|
|
59
|
+
return {
|
|
60
|
+
auth_url: oauth.authorizationEndpoint,
|
|
61
|
+
kind: "oauth2",
|
|
62
|
+
scopes: oauth.scopes,
|
|
63
|
+
token_url: oauth.tokenEndpoint,
|
|
64
|
+
...(dcr
|
|
65
|
+
? {
|
|
66
|
+
dcr: true,
|
|
67
|
+
registration_endpoint: oauth.registrationEndpoint,
|
|
68
|
+
}
|
|
69
|
+
: {}),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
/** A credential id reduced to a stored field key. */
|
|
75
|
+
function fieldKey(credentialId) {
|
|
76
|
+
const key = credentialId
|
|
77
|
+
.toLowerCase()
|
|
78
|
+
.replace(/[^a-z0-9]+/gu, "_")
|
|
79
|
+
.replace(/^_+|_+$/gu, "")
|
|
80
|
+
.slice(0, 40);
|
|
81
|
+
return key || "api_key";
|
|
82
|
+
}
|
|
83
|
+
/** Whether a mechanic describes an OAuth flow rather than a static credential. */
|
|
84
|
+
function isOauthMechanics(mechanics) {
|
|
85
|
+
if (mechanics.source === "well-known") {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
return (mechanics.source === "spec" &&
|
|
89
|
+
(mechanics.scheme ?? "").toLowerCase().includes("oauth"));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Map one registry auth alternative. Returns null when this alternative is not
|
|
93
|
+
* expressible — the caller tries the next one before giving up.
|
|
94
|
+
*/
|
|
95
|
+
function mapSurfaceAuthEntry(params) {
|
|
96
|
+
const { entry } = params;
|
|
97
|
+
if (entry.use.length === 0) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
if (entry.use.length === 1 && isOauthMechanics(entry.use[0].mechanics)) {
|
|
101
|
+
return params.discover ? mapAuthFromRegistry(params.discover) : null;
|
|
102
|
+
}
|
|
103
|
+
// A single header/query credential is the only static placement the stored
|
|
104
|
+
// config can express; multi-credential alternatives (client id + secret
|
|
105
|
+
// headers) have no single placement and fall through to the next entry.
|
|
106
|
+
if (entry.use.length !== 1) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const { id, mechanics } = entry.use[0];
|
|
110
|
+
if (mechanics.source !== "http") {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
const placementIn = mechanics.in === "query" ? "query" : "header";
|
|
114
|
+
const name = mechanics.headerName ?? (placementIn === "query" ? "api_key" : "X-API-Key");
|
|
115
|
+
if (placementIn === "header" && !mechanics.headerName) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const key = fieldKey(id);
|
|
119
|
+
const scheme = mechanics.scheme?.trim();
|
|
120
|
+
return {
|
|
121
|
+
fields: [
|
|
122
|
+
{
|
|
123
|
+
key,
|
|
124
|
+
label: params.credentialLabel(id),
|
|
125
|
+
required: true,
|
|
126
|
+
secret: true,
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
kind: "api_key",
|
|
130
|
+
placement: {
|
|
131
|
+
in: placementIn,
|
|
132
|
+
name,
|
|
133
|
+
value_template: scheme ? `${scheme} {{${key}}}` : `{{${key}}}`,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/** Human-readable summary of what the registry said, for reject reasons. */
|
|
138
|
+
function describeSurfaceAuth(surface) {
|
|
139
|
+
if (surface.auth.entries.length === 0) {
|
|
140
|
+
return `auth status "${surface.auth.status}" with no credential facts`;
|
|
141
|
+
}
|
|
142
|
+
const shapes = surface.auth.entries.map((entry) => entry.use.map((use) => `${use.id} via ${use.mechanics.source}`).join(" + "));
|
|
143
|
+
return `alternatives: ${shapes.join("; ")}`;
|
|
144
|
+
}
|
|
145
|
+
export function mapAuth(params) {
|
|
146
|
+
const surface = params.surface ?? null;
|
|
147
|
+
if (surface?.auth.status === "none") {
|
|
148
|
+
return { auth: { kind: "none" }, ok: true };
|
|
149
|
+
}
|
|
150
|
+
if (params.securitySchemes) {
|
|
151
|
+
const fromSpec = mapAuthFromSecuritySchemes(params.securitySchemes);
|
|
152
|
+
if (fromSpec) {
|
|
153
|
+
return { auth: fromSpec, ok: true };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (surface) {
|
|
157
|
+
const credentials = params.discover?.credentials ?? {};
|
|
158
|
+
const credentialLabel = (id) => credentials[id]?.label ?? "API credential";
|
|
159
|
+
for (const entry of surface.auth.entries) {
|
|
160
|
+
const mapped = mapSurfaceAuthEntry({
|
|
161
|
+
credentialLabel,
|
|
162
|
+
discover: params.discover ?? null,
|
|
163
|
+
entry,
|
|
164
|
+
});
|
|
165
|
+
if (mapped) {
|
|
166
|
+
return { auth: mapped, ok: true };
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (params.discover) {
|
|
171
|
+
const fromRegistry = mapAuthFromRegistry(params.discover);
|
|
172
|
+
if (fromRegistry) {
|
|
173
|
+
return { auth: fromRegistry, ok: true };
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const found = surface
|
|
177
|
+
? describeSurfaceAuth(surface)
|
|
178
|
+
: params.sourceKind === "openapi"
|
|
179
|
+
? "no usable securitySchemes in the spec"
|
|
180
|
+
: "no registry auth facts for this endpoint";
|
|
181
|
+
return {
|
|
182
|
+
ok: false,
|
|
183
|
+
reason: `cannot map authentication (${found}) — supported: no auth, OAuth 2 authorization_code, or a single header/query API key`,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { mcpListTools } from "../invoke/mcp-client.js";
|
|
2
|
+
import { classifyMcpTool } from "./classify.js";
|
|
3
|
+
import { MAX_ACTIONS_PER_CONNECTOR } from "./normalize-openapi.js";
|
|
4
|
+
function humanizeToolName(name) {
|
|
5
|
+
const words = name
|
|
6
|
+
.replace(/([a-z0-9])([A-Z])/gu, "$1 $2")
|
|
7
|
+
.replace(/[_\-.]+/gu, " ")
|
|
8
|
+
.trim();
|
|
9
|
+
return words ? words[0].toUpperCase() + words.slice(1).toLowerCase() : name;
|
|
10
|
+
}
|
|
11
|
+
/** MCP server tools/list → normalized actions. */
|
|
12
|
+
export async function normalizeMcpServer(params) {
|
|
13
|
+
const tools = await mcpListTools(params);
|
|
14
|
+
const actions = [];
|
|
15
|
+
const skipped = [];
|
|
16
|
+
const seenIds = new Set();
|
|
17
|
+
let droppedCount = 0;
|
|
18
|
+
for (const tool of tools) {
|
|
19
|
+
if (actions.length >= MAX_ACTIONS_PER_CONNECTOR) {
|
|
20
|
+
droppedCount += 1;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const id = tool.name
|
|
24
|
+
.replace(/[^a-zA-Z0-9]+/gu, "_")
|
|
25
|
+
.replace(/^_+|_+$/gu, "")
|
|
26
|
+
.toLowerCase()
|
|
27
|
+
.slice(0, 60);
|
|
28
|
+
if (!id || seenIds.has(id)) {
|
|
29
|
+
skipped.push({
|
|
30
|
+
id: tool.name,
|
|
31
|
+
reason: id ? "duplicate tool name" : "unusable tool name",
|
|
32
|
+
});
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
seenIds.add(id);
|
|
36
|
+
// Humanize bare tool names ("read_wiki_structure" → "Read wiki structure")
|
|
37
|
+
// so catalogs, the permissions matrix, and approval cards read naturally.
|
|
38
|
+
const summary = tool.title ?? humanizeToolName(tool.name);
|
|
39
|
+
actions.push({
|
|
40
|
+
classification: classifyMcpTool(tool.annotations ?? {}),
|
|
41
|
+
description: tool.description ?? summary,
|
|
42
|
+
id,
|
|
43
|
+
input_json_schema: tool.inputSchema ?? {
|
|
44
|
+
additionalProperties: false,
|
|
45
|
+
properties: {},
|
|
46
|
+
type: "object",
|
|
47
|
+
},
|
|
48
|
+
invoke: { kind: "mcp", tool_name: tool.name },
|
|
49
|
+
summary,
|
|
50
|
+
tags: [],
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
actions,
|
|
55
|
+
applied_overrides: 0,
|
|
56
|
+
base_url: null,
|
|
57
|
+
description: null,
|
|
58
|
+
dropped_count: droppedCount,
|
|
59
|
+
security_schemes: null,
|
|
60
|
+
skipped,
|
|
61
|
+
title: null,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { ImportValidationError } from "../errors.js";
|
|
2
|
+
import { classifyHttpOperation } from "./classify.js";
|
|
3
|
+
/**
|
|
4
|
+
* OpenAPI spec text → normalized actions, via the executor openapi core
|
|
5
|
+
* (`parse` + `extract` handle $refs, parameter styles, and merge path/query/
|
|
6
|
+
* header/body params into one JSON-Schema input with the body under `body`).
|
|
7
|
+
*
|
|
8
|
+
* The executor/effect packages are imported LAZILY: they run ONLY at admin
|
|
9
|
+
* import/refresh time, never at plugin boot or action execute time — the
|
|
10
|
+
* stored `NormalizedAction[]` is what boot and execute consume. (Same
|
|
11
|
+
* lazy-import posture the AI app uses for heavyweight optional deps.)
|
|
12
|
+
*
|
|
13
|
+
* Registry `specOverrides` are RFC 6902 patches the registry publishes to
|
|
14
|
+
* correct a published spec (Figma's truncated OAuth scopes, say). They are
|
|
15
|
+
* applied to the parsed document *before* extraction, and a patch that does
|
|
16
|
+
* not apply fails the import instead of silently normalizing the unpatched
|
|
17
|
+
* spec.
|
|
18
|
+
*/
|
|
19
|
+
/** Hard cap per connector; drops are counted and surfaced, never silent. */
|
|
20
|
+
export const MAX_ACTIONS_PER_CONNECTOR = 500;
|
|
21
|
+
/** Spec size ceiling, checked before the body is read and again after. */
|
|
22
|
+
export const MAX_SPEC_BYTES = 5 * 1024 * 1024;
|
|
23
|
+
function snakeCaseId(raw) {
|
|
24
|
+
return raw
|
|
25
|
+
.replace(/([a-z0-9])([A-Z])/gu, "$1_$2")
|
|
26
|
+
.replace(/[^a-zA-Z0-9]+/gu, "_")
|
|
27
|
+
.replace(/^_+|_+$/gu, "")
|
|
28
|
+
.toLowerCase()
|
|
29
|
+
.slice(0, 60);
|
|
30
|
+
}
|
|
31
|
+
export async function normalizeOpenApiSpec(specText, options) {
|
|
32
|
+
if (Buffer.byteLength(specText, "utf8") > MAX_SPEC_BYTES) {
|
|
33
|
+
throw new ImportValidationError(`spec too large (> ${MAX_SPEC_BYTES / (1024 * 1024)} MB); import a smaller spec or use a filtered variant`);
|
|
34
|
+
}
|
|
35
|
+
const overrides = options?.specOverrides ?? [];
|
|
36
|
+
const [{ extract, parse }, { Effect, Option }] = await Promise.all([
|
|
37
|
+
import("@executor-js/plugin-openapi/core"),
|
|
38
|
+
import("effect"),
|
|
39
|
+
]);
|
|
40
|
+
const optional = (value) => Option.getOrUndefined(value);
|
|
41
|
+
const doc = await Effect.runPromise(parse(specText));
|
|
42
|
+
if (overrides.length > 0) {
|
|
43
|
+
const { applyPatch } = await import("rfc6902");
|
|
44
|
+
const failures = applyPatch(doc, overrides).filter((error) => error !== null);
|
|
45
|
+
if (failures.length > 0) {
|
|
46
|
+
throw new ImportValidationError(`registry spec overrides do not apply to this spec: ${failures
|
|
47
|
+
.map((error) => error.message)
|
|
48
|
+
.join("; ")}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const extracted = await Effect.runPromise(extract(doc));
|
|
52
|
+
/** Substitute server-URL variables with their declared defaults. */
|
|
53
|
+
const resolveServerBaseUrl = () => {
|
|
54
|
+
const server = extracted.servers[0];
|
|
55
|
+
if (!server) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const variables = optional(server.variables) ?? {};
|
|
59
|
+
const url = server.url.replace(/\{([^}]+)\}/gu, (match, name) => variables[name]?.default ?? match);
|
|
60
|
+
return url.replace(/\/+$/u, "");
|
|
61
|
+
};
|
|
62
|
+
const actions = [];
|
|
63
|
+
const skipped = [];
|
|
64
|
+
const seenIds = new Set();
|
|
65
|
+
let droppedCount = 0;
|
|
66
|
+
for (const op of extracted.operations) {
|
|
67
|
+
if (op.deprecated) {
|
|
68
|
+
skipped.push({ id: op.operationId, reason: "deprecated" });
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (actions.length >= MAX_ACTIONS_PER_CONNECTOR) {
|
|
72
|
+
droppedCount += 1;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
let id = snakeCaseId(op.operationId);
|
|
76
|
+
if (!id) {
|
|
77
|
+
id = snakeCaseId(`${op.method}_${op.pathTemplate}`);
|
|
78
|
+
}
|
|
79
|
+
if (!id) {
|
|
80
|
+
skipped.push({ id: op.operationId, reason: "unusable operation id" });
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
while (seenIds.has(id)) {
|
|
84
|
+
id = `${id}_${op.method.toLowerCase()}`.slice(0, 60);
|
|
85
|
+
if (seenIds.has(id)) {
|
|
86
|
+
id = `${id}2`;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
seenIds.add(id);
|
|
90
|
+
const inputSchema = optional(op.inputSchema);
|
|
91
|
+
const requestBody = optional(op.requestBody);
|
|
92
|
+
const summary = optional(op.summary) ??
|
|
93
|
+
`${op.method.toUpperCase()} ${op.pathTemplate}`;
|
|
94
|
+
actions.push({
|
|
95
|
+
classification: classifyHttpOperation(op.method, op.pathTemplate),
|
|
96
|
+
description: optional(op.description) ?? summary,
|
|
97
|
+
id,
|
|
98
|
+
input_json_schema: inputSchema ?? {
|
|
99
|
+
additionalProperties: false,
|
|
100
|
+
properties: {},
|
|
101
|
+
type: "object",
|
|
102
|
+
},
|
|
103
|
+
invoke: {
|
|
104
|
+
body_content_type: requestBody?.contentType ?? null,
|
|
105
|
+
kind: "http",
|
|
106
|
+
method: op.method,
|
|
107
|
+
params: op.parameters.map((param) => ({
|
|
108
|
+
location: param.location,
|
|
109
|
+
name: param.name,
|
|
110
|
+
required: param.required,
|
|
111
|
+
})),
|
|
112
|
+
path_template: op.pathTemplate,
|
|
113
|
+
},
|
|
114
|
+
summary,
|
|
115
|
+
tags: [...op.tags],
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
const securitySchemes = doc
|
|
119
|
+
.components?.securitySchemes ?? null;
|
|
120
|
+
return {
|
|
121
|
+
actions,
|
|
122
|
+
applied_overrides: overrides.length,
|
|
123
|
+
base_url: resolveServerBaseUrl(),
|
|
124
|
+
description: optional(extracted.description) ?? null,
|
|
125
|
+
dropped_count: droppedCount,
|
|
126
|
+
security_schemes: securitySchemes,
|
|
127
|
+
skipped,
|
|
128
|
+
title: optional(extracted.title) ?? null,
|
|
129
|
+
};
|
|
130
|
+
}
|