@nimrobo/mcporter-remote 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +7 -0
- package/.gitattributes +2 -0
- package/.github/workflows/ci.yml +26 -0
- package/AGENTS.md +109 -0
- package/CHANGELOG.md +361 -0
- package/LICENSE +21 -0
- package/README.md +449 -0
- package/bin/git +180 -0
- package/biome.json +43 -0
- package/config/mcporter.json +134 -0
- package/dist/cli/adhoc-server.d.ts +21 -0
- package/dist/cli/adhoc-server.d.ts.map +1 -0
- package/dist/cli/adhoc-server.js +228 -0
- package/dist/cli/adhoc-server.js.map +1 -0
- package/dist/cli/auth-command.d.ts +6 -0
- package/dist/cli/auth-command.d.ts.map +1 -0
- package/dist/cli/auth-command.js +257 -0
- package/dist/cli/auth-command.js.map +1 -0
- package/dist/cli/call-argument-expression.d.ts +5 -0
- package/dist/cli/call-argument-expression.d.ts.map +1 -0
- package/dist/cli/call-argument-expression.js +57 -0
- package/dist/cli/call-argument-expression.js.map +1 -0
- package/dist/cli/call-argument-values.d.ts +10 -0
- package/dist/cli/call-argument-values.d.ts.map +1 -0
- package/dist/cli/call-argument-values.js +83 -0
- package/dist/cli/call-argument-values.js.map +1 -0
- package/dist/cli/call-arguments.d.ts +17 -0
- package/dist/cli/call-arguments.d.ts.map +1 -0
- package/dist/cli/call-arguments.js +183 -0
- package/dist/cli/call-arguments.js.map +1 -0
- package/dist/cli/call-command.d.ts +5 -0
- package/dist/cli/call-command.d.ts.map +1 -0
- package/dist/cli/call-command.js +371 -0
- package/dist/cli/call-command.js.map +1 -0
- package/dist/cli/call-expression-parser.d.ts +9 -0
- package/dist/cli/call-expression-parser.d.ts.map +1 -0
- package/dist/cli/call-expression-parser.js +177 -0
- package/dist/cli/call-expression-parser.js.map +1 -0
- package/dist/cli/cli-factory.d.ts +16 -0
- package/dist/cli/cli-factory.d.ts.map +1 -0
- package/dist/cli/cli-factory.js +37 -0
- package/dist/cli/cli-factory.js.map +1 -0
- package/dist/cli/command-inference.d.ts +12 -0
- package/dist/cli/command-inference.d.ts.map +1 -0
- package/dist/cli/command-inference.js +75 -0
- package/dist/cli/command-inference.js.map +1 -0
- package/dist/cli/config/add.d.ts +23 -0
- package/dist/cli/config/add.d.ts.map +1 -0
- package/dist/cli/config/add.js +267 -0
- package/dist/cli/config/add.js.map +1 -0
- package/dist/cli/config/auth.d.ts +4 -0
- package/dist/cli/config/auth.d.ts.map +1 -0
- package/dist/cli/config/auth.js +21 -0
- package/dist/cli/config/auth.js.map +1 -0
- package/dist/cli/config/doctor.d.ts +3 -0
- package/dist/cli/config/doctor.d.ts.map +1 -0
- package/dist/cli/config/doctor.js +26 -0
- package/dist/cli/config/doctor.js.map +1 -0
- package/dist/cli/config/get.d.ts +3 -0
- package/dist/cli/config/get.d.ts.map +1 -0
- package/dist/cli/config/get.js +45 -0
- package/dist/cli/config/get.js.map +1 -0
- package/dist/cli/config/help.d.ts +18 -0
- package/dist/cli/config/help.d.ts.map +1 -0
- package/dist/cli/config/help.js +193 -0
- package/dist/cli/config/help.js.map +1 -0
- package/dist/cli/config/import.d.ts +9 -0
- package/dist/cli/config/import.d.ts.map +1 -0
- package/dist/cli/config/import.js +88 -0
- package/dist/cli/config/import.js.map +1 -0
- package/dist/cli/config/index.d.ts +2 -0
- package/dist/cli/config/index.d.ts.map +1 -0
- package/dist/cli/config/index.js +2 -0
- package/dist/cli/config/index.js.map +1 -0
- package/dist/cli/config/list.d.ts +7 -0
- package/dist/cli/config/list.d.ts.map +1 -0
- package/dist/cli/config/list.js +71 -0
- package/dist/cli/config/list.js.map +1 -0
- package/dist/cli/config/remove.d.ts +3 -0
- package/dist/cli/config/remove.d.ts.map +1 -0
- package/dist/cli/config/remove.js +19 -0
- package/dist/cli/config/remove.js.map +1 -0
- package/dist/cli/config/render.d.ts +26 -0
- package/dist/cli/config/render.d.ts.map +1 -0
- package/dist/cli/config/render.js +99 -0
- package/dist/cli/config/render.js.map +1 -0
- package/dist/cli/config/shared.d.ts +21 -0
- package/dist/cli/config/shared.d.ts.map +1 -0
- package/dist/cli/config/shared.js +130 -0
- package/dist/cli/config/shared.js.map +1 -0
- package/dist/cli/config/types.d.ts +7 -0
- package/dist/cli/config/types.d.ts.map +1 -0
- package/dist/cli/config/types.js +2 -0
- package/dist/cli/config/types.js.map +1 -0
- package/dist/cli/config-command.d.ts +7 -0
- package/dist/cli/config-command.d.ts.map +1 -0
- package/dist/cli/config-command.js +67 -0
- package/dist/cli/config-command.js.map +1 -0
- package/dist/cli/daemon-command.d.ts +8 -0
- package/dist/cli/daemon-command.d.ts.map +1 -0
- package/dist/cli/daemon-command.js +219 -0
- package/dist/cli/daemon-command.js.map +1 -0
- package/dist/cli/emit-ts-command.d.ts +31 -0
- package/dist/cli/emit-ts-command.d.ts.map +1 -0
- package/dist/cli/emit-ts-command.js +217 -0
- package/dist/cli/emit-ts-command.js.map +1 -0
- package/dist/cli/emit-ts-templates.d.ts +23 -0
- package/dist/cli/emit-ts-templates.d.ts.map +1 -0
- package/dist/cli/emit-ts-templates.js +130 -0
- package/dist/cli/emit-ts-templates.js.map +1 -0
- package/dist/cli/ephemeral-flags.d.ts +7 -0
- package/dist/cli/ephemeral-flags.d.ts.map +1 -0
- package/dist/cli/ephemeral-flags.js +108 -0
- package/dist/cli/ephemeral-flags.js.map +1 -0
- package/dist/cli/ephemeral-target.d.ts +16 -0
- package/dist/cli/ephemeral-target.d.ts.map +1 -0
- package/dist/cli/ephemeral-target.js +105 -0
- package/dist/cli/ephemeral-target.js.map +1 -0
- package/dist/cli/errors.d.ts +4 -0
- package/dist/cli/errors.d.ts.map +1 -0
- package/dist/cli/errors.js +7 -0
- package/dist/cli/errors.js.map +1 -0
- package/dist/cli/flag-utils.d.ts +4 -0
- package/dist/cli/flag-utils.d.ts.map +1 -0
- package/dist/cli/flag-utils.js +27 -0
- package/dist/cli/flag-utils.js.map +1 -0
- package/dist/cli/generate/artifacts.d.ts +15 -0
- package/dist/cli/generate/artifacts.d.ts.map +1 -0
- package/dist/cli/generate/artifacts.js +247 -0
- package/dist/cli/generate/artifacts.js.map +1 -0
- package/dist/cli/generate/definition.d.ts +22 -0
- package/dist/cli/generate/definition.d.ts.map +1 -0
- package/dist/cli/generate/definition.js +265 -0
- package/dist/cli/generate/definition.js.map +1 -0
- package/dist/cli/generate/flag-parser.d.ts +11 -0
- package/dist/cli/generate/flag-parser.d.ts.map +1 -0
- package/dist/cli/generate/flag-parser.js +41 -0
- package/dist/cli/generate/flag-parser.js.map +1 -0
- package/dist/cli/generate/flags.d.ts +20 -0
- package/dist/cli/generate/flags.d.ts.map +1 -0
- package/dist/cli/generate/flags.js +220 -0
- package/dist/cli/generate/flags.js.map +1 -0
- package/dist/cli/generate/fs-helpers.d.ts +3 -0
- package/dist/cli/generate/fs-helpers.d.ts.map +1 -0
- package/dist/cli/generate/fs-helpers.js +34 -0
- package/dist/cli/generate/fs-helpers.js.map +1 -0
- package/dist/cli/generate/name-utils.d.ts +5 -0
- package/dist/cli/generate/name-utils.d.ts.map +1 -0
- package/dist/cli/generate/name-utils.js +170 -0
- package/dist/cli/generate/name-utils.js.map +1 -0
- package/dist/cli/generate/output.d.ts +5 -0
- package/dist/cli/generate/output.d.ts.map +1 -0
- package/dist/cli/generate/output.js +24 -0
- package/dist/cli/generate/output.js.map +1 -0
- package/dist/cli/generate/runtime.d.ts +3 -0
- package/dist/cli/generate/runtime.d.ts.map +1 -0
- package/dist/cli/generate/runtime.js +34 -0
- package/dist/cli/generate/runtime.js.map +1 -0
- package/dist/cli/generate/server-utils.d.ts +3 -0
- package/dist/cli/generate/server-utils.d.ts.map +1 -0
- package/dist/cli/generate/server-utils.js +33 -0
- package/dist/cli/generate/server-utils.js.map +1 -0
- package/dist/cli/generate/template-data.d.ts +25 -0
- package/dist/cli/generate/template-data.d.ts.map +1 -0
- package/dist/cli/generate/template-data.js +90 -0
- package/dist/cli/generate/template-data.js.map +1 -0
- package/dist/cli/generate/template-help.d.ts +2 -0
- package/dist/cli/generate/template-help.d.ts.map +1 -0
- package/dist/cli/generate/template-help.js +113 -0
- package/dist/cli/generate/template-help.js.map +1 -0
- package/dist/cli/generate/template.d.ts +30 -0
- package/dist/cli/generate/template.d.ts.map +1 -0
- package/dist/cli/generate/template.js +366 -0
- package/dist/cli/generate/template.js.map +1 -0
- package/dist/cli/generate/tools.d.ts +46 -0
- package/dist/cli/generate/tools.d.ts.map +1 -0
- package/dist/cli/generate/tools.js +304 -0
- package/dist/cli/generate/tools.js.map +1 -0
- package/dist/cli/generate/types.d.ts +5 -0
- package/dist/cli/generate/types.d.ts.map +1 -0
- package/dist/cli/generate/types.js +2 -0
- package/dist/cli/generate/types.js.map +1 -0
- package/dist/cli/generate-cli-runner.d.ts +3 -0
- package/dist/cli/generate-cli-runner.d.ts.map +1 -0
- package/dist/cli/generate-cli-runner.js +72 -0
- package/dist/cli/generate-cli-runner.js.map +1 -0
- package/dist/cli/help-output.d.ts +6 -0
- package/dist/cli/help-output.d.ts.map +1 -0
- package/dist/cli/help-output.js +186 -0
- package/dist/cli/help-output.js.map +1 -0
- package/dist/cli/http-utils.d.ts +9 -0
- package/dist/cli/http-utils.d.ts.map +1 -0
- package/dist/cli/http-utils.js +88 -0
- package/dist/cli/http-utils.js.map +1 -0
- package/dist/cli/identifier-helpers.d.ts +20 -0
- package/dist/cli/identifier-helpers.d.ts.map +1 -0
- package/dist/cli/identifier-helpers.js +84 -0
- package/dist/cli/identifier-helpers.js.map +1 -0
- package/dist/cli/image-output.d.ts +3 -0
- package/dist/cli/image-output.d.ts.map +1 -0
- package/dist/cli/image-output.js +57 -0
- package/dist/cli/image-output.js.map +1 -0
- package/dist/cli/inspect-cli-command.d.ts +11 -0
- package/dist/cli/inspect-cli-command.d.ts.map +1 -0
- package/dist/cli/inspect-cli-command.js +78 -0
- package/dist/cli/inspect-cli-command.js.map +1 -0
- package/dist/cli/json-output.d.ts +23 -0
- package/dist/cli/json-output.d.ts.map +1 -0
- package/dist/cli/json-output.js +38 -0
- package/dist/cli/json-output.js.map +1 -0
- package/dist/cli/list-command.d.ts +15 -0
- package/dist/cli/list-command.d.ts.map +1 -0
- package/dist/cli/list-command.js +372 -0
- package/dist/cli/list-command.js.map +1 -0
- package/dist/cli/list-detail-helpers.d.ts +41 -0
- package/dist/cli/list-detail-helpers.d.ts.map +1 -0
- package/dist/cli/list-detail-helpers.js +99 -0
- package/dist/cli/list-detail-helpers.js.map +1 -0
- package/dist/cli/list-doc-comments.d.ts +6 -0
- package/dist/cli/list-doc-comments.d.ts.map +1 -0
- package/dist/cli/list-doc-comments.js +114 -0
- package/dist/cli/list-doc-comments.js.map +1 -0
- package/dist/cli/list-format.d.ts +38 -0
- package/dist/cli/list-format.d.ts.map +1 -0
- package/dist/cli/list-format.js +98 -0
- package/dist/cli/list-format.js.map +1 -0
- package/dist/cli/list-output.d.ts +39 -0
- package/dist/cli/list-output.d.ts.map +1 -0
- package/dist/cli/list-output.js +159 -0
- package/dist/cli/list-output.js.map +1 -0
- package/dist/cli/list-signature.d.ts +26 -0
- package/dist/cli/list-signature.d.ts.map +1 -0
- package/dist/cli/list-signature.js +176 -0
- package/dist/cli/list-signature.js.map +1 -0
- package/dist/cli/logger-context.d.ts +9 -0
- package/dist/cli/logger-context.d.ts.map +1 -0
- package/dist/cli/logger-context.js +29 -0
- package/dist/cli/logger-context.js.map +1 -0
- package/dist/cli/output-format.d.ts +11 -0
- package/dist/cli/output-format.d.ts.map +1 -0
- package/dist/cli/output-format.js +51 -0
- package/dist/cli/output-format.js.map +1 -0
- package/dist/cli/output-utils.d.ts +5 -0
- package/dist/cli/output-utils.d.ts.map +1 -0
- package/dist/cli/output-utils.js +143 -0
- package/dist/cli/output-utils.js.map +1 -0
- package/dist/cli/path-utils.d.ts +2 -0
- package/dist/cli/path-utils.d.ts.map +1 -0
- package/dist/cli/path-utils.js +12 -0
- package/dist/cli/path-utils.js.map +1 -0
- package/dist/cli/runtime-debug.d.ts +4 -0
- package/dist/cli/runtime-debug.d.ts.map +1 -0
- package/dist/cli/runtime-debug.js +134 -0
- package/dist/cli/runtime-debug.js.map +1 -0
- package/dist/cli/server-lookup.d.ts +3 -0
- package/dist/cli/server-lookup.d.ts.map +1 -0
- package/dist/cli/server-lookup.js +21 -0
- package/dist/cli/server-lookup.js.map +1 -0
- package/dist/cli/terminal.d.ts +10 -0
- package/dist/cli/terminal.d.ts.map +1 -0
- package/dist/cli/terminal.js +33 -0
- package/dist/cli/terminal.js.map +1 -0
- package/dist/cli/timeouts.d.ts +9 -0
- package/dist/cli/timeouts.d.ts.map +1 -0
- package/dist/cli/timeouts.js +55 -0
- package/dist/cli/timeouts.js.map +1 -0
- package/dist/cli/tool-cache.d.ts +9 -0
- package/dist/cli/tool-cache.d.ts.map +1 -0
- package/dist/cli/tool-cache.js +31 -0
- package/dist/cli/tool-cache.js.map +1 -0
- package/dist/cli/transport-utils.d.ts +3 -0
- package/dist/cli/transport-utils.d.ts.map +1 -0
- package/dist/cli/transport-utils.js +9 -0
- package/dist/cli/transport-utils.js.map +1 -0
- package/dist/cli-metadata.d.ts +57 -0
- package/dist/cli-metadata.d.ts.map +1 -0
- package/dist/cli-metadata.js +92 -0
- package/dist/cli-metadata.js.map +1 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +217 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/imports/external.d.ts +8 -0
- package/dist/config/imports/external.d.ts.map +1 -0
- package/dist/config/imports/external.js +231 -0
- package/dist/config/imports/external.js.map +1 -0
- package/dist/config/imports/paths-utils.d.ts +3 -0
- package/dist/config/imports/paths-utils.d.ts.map +1 -0
- package/dist/config/imports/paths-utils.js +27 -0
- package/dist/config/imports/paths-utils.js.map +1 -0
- package/dist/config/imports/paths.d.ts +3 -0
- package/dist/config/imports/paths.d.ts.map +1 -0
- package/dist/config/imports/paths.js +135 -0
- package/dist/config/imports/paths.js.map +1 -0
- package/dist/config/imports/shared.d.ts +4 -0
- package/dist/config/imports/shared.d.ts.map +1 -0
- package/dist/config/imports/shared.js +25 -0
- package/dist/config/imports/shared.js.map +1 -0
- package/dist/config/path-discovery.d.ts +11 -0
- package/dist/config/path-discovery.d.ts.map +1 -0
- package/dist/config/path-discovery.js +65 -0
- package/dist/config/path-discovery.js.map +1 -0
- package/dist/config/read-config.d.ts +9 -0
- package/dist/config/read-config.d.ts.map +1 -0
- package/dist/config/read-config.js +74 -0
- package/dist/config/read-config.js.map +1 -0
- package/dist/config-imports.d.ts +7 -0
- package/dist/config-imports.d.ts.map +1 -0
- package/dist/config-imports.js +8 -0
- package/dist/config-imports.js.map +1 -0
- package/dist/config-normalize.d.ts +8 -0
- package/dist/config-normalize.d.ts.map +1 -0
- package/dist/config-normalize.js +184 -0
- package/dist/config-normalize.js.map +1 -0
- package/dist/config-schema.d.ts +164 -0
- package/dist/config-schema.d.ts.map +1 -0
- package/dist/config-schema.js +103 -0
- package/dist/config-schema.js.map +1 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +91 -0
- package/dist/config.js.map +1 -0
- package/dist/daemon/client.d.ts +34 -0
- package/dist/daemon/client.d.ts.map +1 -0
- package/dist/daemon/client.js +291 -0
- package/dist/daemon/client.js.map +1 -0
- package/dist/daemon/config-layers.d.ts +7 -0
- package/dist/daemon/config-layers.d.ts.map +1 -0
- package/dist/daemon/config-layers.js +20 -0
- package/dist/daemon/config-layers.js.map +1 -0
- package/dist/daemon/host.d.ts +32 -0
- package/dist/daemon/host.d.ts.map +1 -0
- package/dist/daemon/host.js +345 -0
- package/dist/daemon/host.js.map +1 -0
- package/dist/daemon/launch.d.ts +10 -0
- package/dist/daemon/launch.d.ts.map +1 -0
- package/dist/daemon/launch.js +35 -0
- package/dist/daemon/launch.js.map +1 -0
- package/dist/daemon/log-context.d.ts +18 -0
- package/dist/daemon/log-context.d.ts.map +1 -0
- package/dist/daemon/log-context.js +64 -0
- package/dist/daemon/log-context.js.map +1 -0
- package/dist/daemon/paths.d.ts +5 -0
- package/dist/daemon/paths.d.ts.map +1 -0
- package/dist/daemon/paths.js +30 -0
- package/dist/daemon/paths.js.map +1 -0
- package/dist/daemon/protocol.d.ts +51 -0
- package/dist/daemon/protocol.d.ts.map +1 -0
- package/dist/daemon/protocol.js +2 -0
- package/dist/daemon/protocol.js.map +1 -0
- package/dist/daemon/request-utils.d.ts +12 -0
- package/dist/daemon/request-utils.d.ts.map +1 -0
- package/dist/daemon/request-utils.js +52 -0
- package/dist/daemon/request-utils.js.map +1 -0
- package/dist/daemon/runtime-wrapper.d.ts +9 -0
- package/dist/daemon/runtime-wrapper.d.ts.map +1 -0
- package/dist/daemon/runtime-wrapper.js +110 -0
- package/dist/daemon/runtime-wrapper.js.map +1 -0
- package/dist/env.d.ts +5 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +93 -0
- package/dist/env.js.map +1 -0
- package/dist/error-classifier.d.ts +11 -0
- package/dist/error-classifier.d.ts.map +1 -0
- package/dist/error-classifier.js +141 -0
- package/dist/error-classifier.js.map +1 -0
- package/dist/fs-json.d.ts +3 -0
- package/dist/fs-json.d.ts.map +1 -0
- package/dist/fs-json.js +21 -0
- package/dist/fs-json.js.map +1 -0
- package/dist/generate-cli.d.ts +32 -0
- package/dist/generate-cli.d.ts.map +1 -0
- package/dist/generate-cli.js +155 -0
- package/dist/generate-cli.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle.d.ts +8 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +106 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/logging.d.ts +19 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +76 -0
- package/dist/logging.js.map +1 -0
- package/dist/oauth-manual.d.ts +9 -0
- package/dist/oauth-manual.d.ts.map +1 -0
- package/dist/oauth-manual.js +84 -0
- package/dist/oauth-manual.js.map +1 -0
- package/dist/oauth-persistence.d.ts +20 -0
- package/dist/oauth-persistence.d.ts.map +1 -0
- package/dist/oauth-persistence.js +254 -0
- package/dist/oauth-persistence.js.map +1 -0
- package/dist/oauth-vault.d.ts +19 -0
- package/dist/oauth-vault.d.ts.map +1 -0
- package/dist/oauth-vault.js +100 -0
- package/dist/oauth-vault.js.map +1 -0
- package/dist/oauth.d.ts +31 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +414 -0
- package/dist/oauth.js.map +1 -0
- package/dist/result-utils.d.ts +22 -0
- package/dist/result-utils.d.ts.map +1 -0
- package/dist/result-utils.js +229 -0
- package/dist/result-utils.js.map +1 -0
- package/dist/runtime/errors.d.ts +2 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/errors.js +16 -0
- package/dist/runtime/errors.js.map +1 -0
- package/dist/runtime/http-transport.d.ts +15 -0
- package/dist/runtime/http-transport.d.ts.map +1 -0
- package/dist/runtime/http-transport.js +91 -0
- package/dist/runtime/http-transport.js.map +1 -0
- package/dist/runtime/manual-oauth.d.ts +8 -0
- package/dist/runtime/manual-oauth.d.ts.map +1 -0
- package/dist/runtime/manual-oauth.js +81 -0
- package/dist/runtime/manual-oauth.js.map +1 -0
- package/dist/runtime/oauth.d.ts +22 -0
- package/dist/runtime/oauth.d.ts.map +1 -0
- package/dist/runtime/oauth.js +83 -0
- package/dist/runtime/oauth.js.map +1 -0
- package/dist/runtime/transport.d.ts +24 -0
- package/dist/runtime/transport.d.ts.map +1 -0
- package/dist/runtime/transport.js +165 -0
- package/dist/runtime/transport.js.map +1 -0
- package/dist/runtime/utils.d.ts +5 -0
- package/dist/runtime/utils.d.ts.map +1 -0
- package/dist/runtime/utils.js +47 -0
- package/dist/runtime/utils.js.map +1 -0
- package/dist/runtime-header-utils.d.ts +2 -0
- package/dist/runtime-header-utils.d.ts.map +1 -0
- package/dist/runtime-header-utils.js +19 -0
- package/dist/runtime-header-utils.js.map +1 -0
- package/dist/runtime-oauth-support.d.ts +5 -0
- package/dist/runtime-oauth-support.d.ts.map +1 -0
- package/dist/runtime-oauth-support.js +21 -0
- package/dist/runtime-oauth-support.js.map +1 -0
- package/dist/runtime-process-utils.d.ts +11 -0
- package/dist/runtime-process-utils.d.ts.map +1 -0
- package/dist/runtime-process-utils.js +299 -0
- package/dist/runtime-process-utils.js.map +1 -0
- package/dist/runtime.d.ts +55 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +245 -0
- package/dist/runtime.js.map +1 -0
- package/dist/schema-cache.d.ts +10 -0
- package/dist/schema-cache.d.ts.map +1 -0
- package/dist/schema-cache.js +40 -0
- package/dist/schema-cache.js.map +1 -0
- package/dist/sdk-patches.d.ts +5 -0
- package/dist/sdk-patches.d.ts.map +1 -0
- package/dist/sdk-patches.js +399 -0
- package/dist/sdk-patches.js.map +1 -0
- package/dist/server-proxy.d.ts +17 -0
- package/dist/server-proxy.d.ts.map +1 -0
- package/dist/server-proxy.js +342 -0
- package/dist/server-proxy.js.map +1 -0
- package/docs/RELEASE.md +96 -0
- package/docs/adhoc.md +76 -0
- package/docs/call-heuristic.md +31 -0
- package/docs/call-syntax.md +75 -0
- package/docs/cli-generator.md +116 -0
- package/docs/cli-reference.md +76 -0
- package/docs/config.md +208 -0
- package/docs/daemon.md +95 -0
- package/docs/emit-ts.md +98 -0
- package/docs/hang-debug.md +88 -0
- package/docs/import.md +59 -0
- package/docs/known-issues.md +33 -0
- package/docs/livetests.md +31 -0
- package/docs/local.md +73 -0
- package/docs/logging.md +67 -0
- package/docs/manual-testing.md +78 -0
- package/docs/mcp.md +44 -0
- package/docs/migration.md +77 -0
- package/docs/pnpm-mcp-migration.md +15 -0
- package/docs/refactor.md +76 -0
- package/docs/shortcuts.md +31 -0
- package/docs/spec.md +86 -0
- package/docs/subagent.md +39 -0
- package/docs/supabase-auth-issue.md +53 -0
- package/docs/tmux.md +30 -0
- package/docs/tool-calling.md +73 -0
- package/docs/windows.md +25 -0
- package/examples/context7-headlines.ts +72 -0
- package/git +3 -0
- package/mcporter.png +0 -0
- package/mcporter.schema.json +263 -0
- package/package.json +105 -0
- package/pnpm-workspace.yaml +2 -0
- package/runner +13 -0
- package/scripts/agent-send.ts +179 -0
- package/scripts/build-bun.ts +125 -0
- package/scripts/committer +53 -0
- package/scripts/docs-list.ts +132 -0
- package/scripts/generate-json-schema.ts +50 -0
- package/scripts/git-policy.ts +165 -0
- package/scripts/mcp_signoz_retry_patch.cjs +9 -0
- package/scripts/release.sh +86 -0
- package/scripts/runner.ts +1556 -0
- package/scripts/test-runner.js +39 -0
- package/src/cli/adhoc-server.ts +263 -0
- package/src/cli/auth-command.ts +290 -0
- package/src/cli/call-argument-expression.ts +61 -0
- package/src/cli/call-argument-values.ts +95 -0
- package/src/cli/call-arguments.ts +246 -0
- package/src/cli/call-command.ts +478 -0
- package/src/cli/call-expression-parser.ts +210 -0
- package/src/cli/cli-factory.ts +51 -0
- package/src/cli/command-inference.ts +99 -0
- package/src/cli/config/add.ts +308 -0
- package/src/cli/config/auth.ts +23 -0
- package/src/cli/config/doctor.ts +27 -0
- package/src/cli/config/get.ts +47 -0
- package/src/cli/config/help.ts +213 -0
- package/src/cli/config/import.ts +97 -0
- package/src/cli/config/index.ts +1 -0
- package/src/cli/config/list.ts +81 -0
- package/src/cli/config/remove.ts +20 -0
- package/src/cli/config/render.ts +119 -0
- package/src/cli/config/shared.ts +159 -0
- package/src/cli/config/types.ts +8 -0
- package/src/cli/config-command.ts +72 -0
- package/src/cli/daemon-command.ts +260 -0
- package/src/cli/emit-ts-command.ts +260 -0
- package/src/cli/emit-ts-templates.ts +161 -0
- package/src/cli/ephemeral-flags.ts +128 -0
- package/src/cli/ephemeral-target.ts +134 -0
- package/src/cli/errors.ts +6 -0
- package/src/cli/flag-utils.ts +29 -0
- package/src/cli/generate/artifacts.ts +308 -0
- package/src/cli/generate/definition.ts +325 -0
- package/src/cli/generate/flag-parser.ts +50 -0
- package/src/cli/generate/flags.ts +248 -0
- package/src/cli/generate/fs-helpers.ts +34 -0
- package/src/cli/generate/name-utils.ts +176 -0
- package/src/cli/generate/output.ts +27 -0
- package/src/cli/generate/runtime.ts +38 -0
- package/src/cli/generate/server-utils.ts +38 -0
- package/src/cli/generate/template-data.ts +126 -0
- package/src/cli/generate/template-help.ts +112 -0
- package/src/cli/generate/template.ts +407 -0
- package/src/cli/generate/tools.ts +354 -0
- package/src/cli/generate/types.ts +1 -0
- package/src/cli/generate-cli-runner.ts +82 -0
- package/src/cli/help-output.ts +207 -0
- package/src/cli/http-utils.ts +89 -0
- package/src/cli/identifier-helpers.ts +107 -0
- package/src/cli/image-output.ts +62 -0
- package/src/cli/inspect-cli-command.ts +89 -0
- package/src/cli/json-output.ts +60 -0
- package/src/cli/list-command.ts +432 -0
- package/src/cli/list-detail-helpers.ts +179 -0
- package/src/cli/list-doc-comments.ts +129 -0
- package/src/cli/list-format.ts +150 -0
- package/src/cli/list-output.ts +224 -0
- package/src/cli/list-signature.ts +217 -0
- package/src/cli/logger-context.ts +36 -0
- package/src/cli/output-format.ts +63 -0
- package/src/cli/output-utils.ts +161 -0
- package/src/cli/path-utils.ts +13 -0
- package/src/cli/runtime-debug.ts +141 -0
- package/src/cli/server-lookup.ts +22 -0
- package/src/cli/terminal.ts +41 -0
- package/src/cli/timeouts.ts +67 -0
- package/src/cli/tool-cache.ts +43 -0
- package/src/cli/transport-utils.ts +10 -0
- package/src/cli-metadata.ts +164 -0
- package/src/cli.ts +234 -0
- package/src/config/imports/external.ts +284 -0
- package/src/config/imports/paths-utils.ts +29 -0
- package/src/config/imports/paths.ts +145 -0
- package/src/config/imports/shared.ts +27 -0
- package/src/config/path-discovery.ts +79 -0
- package/src/config/read-config.ts +91 -0
- package/src/config-imports.ts +12 -0
- package/src/config-normalize.ts +220 -0
- package/src/config-schema.ts +175 -0
- package/src/config.ts +136 -0
- package/src/daemon/client.ts +350 -0
- package/src/daemon/config-layers.ts +23 -0
- package/src/daemon/host.ts +455 -0
- package/src/daemon/launch.ts +45 -0
- package/src/daemon/log-context.ts +78 -0
- package/src/daemon/paths.ts +35 -0
- package/src/daemon/protocol.ts +57 -0
- package/src/daemon/request-utils.ts +67 -0
- package/src/daemon/runtime-wrapper.ts +135 -0
- package/src/env.ts +107 -0
- package/src/error-classifier.ts +158 -0
- package/src/fs-json.ts +21 -0
- package/src/generate-cli.ts +211 -0
- package/src/index.ts +14 -0
- package/src/lifecycle.ts +138 -0
- package/src/logging.ts +93 -0
- package/src/oauth-manual.ts +103 -0
- package/src/oauth-persistence.ts +316 -0
- package/src/oauth-vault.ts +128 -0
- package/src/oauth.ts +494 -0
- package/src/result-utils.ts +278 -0
- package/src/runtime/errors.ts +17 -0
- package/src/runtime/oauth.ts +112 -0
- package/src/runtime/transport.ts +198 -0
- package/src/runtime/utils.ts +54 -0
- package/src/runtime-header-utils.ts +23 -0
- package/src/runtime-oauth-support.ts +24 -0
- package/src/runtime-process-utils.ts +324 -0
- package/src/runtime.ts +321 -0
- package/src/schema-cache.ts +49 -0
- package/src/sdk-patches.ts +498 -0
- package/src/server-proxy.ts +407 -0
- package/tests/adhoc-server.test.ts +49 -0
- package/tests/call-arguments.test.ts +111 -0
- package/tests/cli-auth-help.test.ts +43 -0
- package/tests/cli-auth-retry.test.ts +41 -0
- package/tests/cli-auth.test.ts +96 -0
- package/tests/cli-call-args.test.ts +69 -0
- package/tests/cli-call-errors.test.ts +27 -0
- package/tests/cli-call-execution.test.ts +279 -0
- package/tests/cli-call-help.test.ts +43 -0
- package/tests/cli-command-inference.test.ts +73 -0
- package/tests/cli-config-command.test.ts +371 -0
- package/tests/cli-config-fallback.test.ts +259 -0
- package/tests/cli-config-routing.test.ts +20 -0
- package/tests/cli-ephemeral-flags.test.ts +54 -0
- package/tests/cli-flag-utils.test.ts +17 -0
- package/tests/cli-generate-artifacts.test.ts +52 -0
- package/tests/cli-generate-cli.integration.test.ts +675 -0
- package/tests/cli-generate-runner.test.ts +156 -0
- package/tests/cli-global-flags.test.ts +61 -0
- package/tests/cli-help-shortcuts.test.ts +42 -0
- package/tests/cli-image-output.test.ts +65 -0
- package/tests/cli-inspect-command.test.ts +15 -0
- package/tests/cli-list-classification.test.ts +291 -0
- package/tests/cli-list-flags.test.ts +83 -0
- package/tests/cli-list-formatting.test.ts +358 -0
- package/tests/cli-list-help.test.ts +43 -0
- package/tests/cli-list-json.test.ts +55 -0
- package/tests/cli-list-stdio-logs.test.ts +108 -0
- package/tests/cli-list-verbose-e2e.test.ts +83 -0
- package/tests/cli-oauth-timeout-flag.test.ts +94 -0
- package/tests/cli-output-utils.test.ts +129 -0
- package/tests/cli-regenerate.test.ts +261 -0
- package/tests/cli-version.test.ts +24 -0
- package/tests/config-add-dry-run.test.ts +45 -0
- package/tests/config-add-flags.test.ts +61 -0
- package/tests/config-add-imports.test.ts +28 -0
- package/tests/config-add-persist.test.ts +27 -0
- package/tests/config-add-scope-behavior.test.ts +46 -0
- package/tests/config-add-scope.test.ts +101 -0
- package/tests/config-add-sse.test.ts +23 -0
- package/tests/config-command-string.test.ts +96 -0
- package/tests/config-doctor.test.ts +45 -0
- package/tests/config-get-json.test.ts +24 -0
- package/tests/config-import-dedupe.test.ts +27 -0
- package/tests/config-import-paths.test.ts +49 -0
- package/tests/config-import.test.ts +64 -0
- package/tests/config-imports-unit.test.ts +337 -0
- package/tests/config-imports.test.ts +417 -0
- package/tests/config-layered.test.ts +178 -0
- package/tests/config-list-text-footer.test.ts +33 -0
- package/tests/config-list.test.ts +62 -0
- package/tests/config-missing.test.ts +140 -0
- package/tests/config-normalize.test.ts +71 -0
- package/tests/config-remove.test.ts +44 -0
- package/tests/config-render.test.ts +61 -0
- package/tests/config-resolution.test.ts +94 -0
- package/tests/config-schema-file.test.ts +29 -0
- package/tests/config-shared.test.ts +41 -0
- package/tests/config-sources.test.ts +58 -0
- package/tests/daemon-cli-command.test.ts +112 -0
- package/tests/daemon-client-config-stale.test.ts +222 -0
- package/tests/daemon-client-timeout.test.ts +114 -0
- package/tests/daemon-client.test.ts +61 -0
- package/tests/daemon-host.test.ts +33 -0
- package/tests/daemon.integration.test.ts +175 -0
- package/tests/emit-ts.test.ts +125 -0
- package/tests/ephemeral-target.test.ts +26 -0
- package/tests/error-classifier.test.ts +46 -0
- package/tests/fixtures/ansi.ts +18 -0
- package/tests/fixtures/cli-list-fixtures.ts +43 -0
- package/tests/fixtures/config-fixture.ts +29 -0
- package/tests/fixtures/imports/.claude/mcp.json +8 -0
- package/tests/fixtures/imports/.claude/settings.json +10 -0
- package/tests/fixtures/imports/.claude/settings.local.json +10 -0
- package/tests/fixtures/imports/.codeium/windsurf/mcp_config.json +14 -0
- package/tests/fixtures/imports/.codex/config.toml +7 -0
- package/tests/fixtures/imports/.config/opencode/opencode.jsonc +10 -0
- package/tests/fixtures/imports/.cursor/mcp.json +14 -0
- package/tests/fixtures/imports/Library/Application Support/Code/User/mcp.json +11 -0
- package/tests/fixtures/imports/config/mcporter.json +11 -0
- package/tests/fixtures/imports/home/.claude/settings.json +7 -0
- package/tests/fixtures/imports/home/.codeium/windsurf/mcp_config.json +14 -0
- package/tests/fixtures/imports/home/.codex/config.toml +7 -0
- package/tests/fixtures/imports/home/Library/Application Support/Code/User/mcp.json +11 -0
- package/tests/fixtures/imports/opencode.jsonc +11 -0
- package/tests/fixtures/mcporter.json +64 -0
- package/tests/fixtures/stdio-filesystem-server.mjs +63 -0
- package/tests/fixtures/stdio-memory-server.mjs +58 -0
- package/tests/fixtures/test-helpers.ts +24 -0
- package/tests/fixtures/tool-fixtures.ts +35 -0
- package/tests/fs-json.test.ts +35 -0
- package/tests/generate-cli-helpers.test.ts +162 -0
- package/tests/generate-cli.test.ts +595 -0
- package/tests/generate-definition.test.ts +25 -0
- package/tests/generator-flag-parser.test.ts +19 -0
- package/tests/index-api.test.ts +136 -0
- package/tests/keep-alive-runtime.test.ts +152 -0
- package/tests/lifecycle.test.ts +29 -0
- package/tests/list-detail-helpers.test.ts +204 -0
- package/tests/list-format.test.ts +40 -0
- package/tests/list-inline-stdio.test.ts +71 -0
- package/tests/list-output.test.ts +138 -0
- package/tests/live/deepwiki-live.test.ts +53 -0
- package/tests/oauth-callback.test.ts +108 -0
- package/tests/oauth-open-external.test.ts +29 -0
- package/tests/oauth-persistence.test.ts +146 -0
- package/tests/oauth-session.test.ts +216 -0
- package/tests/result-utils.test.ts +254 -0
- package/tests/runtime-call-timeout.test.ts +75 -0
- package/tests/runtime-compose.test.ts +298 -0
- package/tests/runtime-error-reset.test.ts +65 -0
- package/tests/runtime-header-utils.test.ts +36 -0
- package/tests/runtime-integration.test.ts +113 -0
- package/tests/runtime-oauth-connect.test.ts +72 -0
- package/tests/runtime-oauth-detection.test.ts +72 -0
- package/tests/runtime-oauth-timeout.test.ts +60 -0
- package/tests/runtime-oauth-utils.test.ts +14 -0
- package/tests/runtime-process-utils.test.ts +53 -0
- package/tests/runtime-transport.test.ts +69 -0
- package/tests/runtime-utils.test.ts +31 -0
- package/tests/runtime.test.ts +94 -0
- package/tests/sdk-patches.test.ts +24 -0
- package/tests/server-proxy.test.ts +336 -0
- package/tests/stdio-servers.integration.test.ts +139 -0
- package/tests/tool-cache.test.ts +42 -0
- package/tests/version-consistency.test.ts +11 -0
- package/tsconfig.build.json +11 -0
- package/tsconfig.json +17 -0
- package/vitest.config.ts +18 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import type { ServerDefinition } from '../config.js';
|
|
4
|
+
import type { Runtime } from '../runtime.js';
|
|
5
|
+
import { type EmitMetadata, renderClientModule, renderTypesModule, type ToolDocEntry } from './emit-ts-templates.js';
|
|
6
|
+
import { extractGeneratorFlags } from './generate/flag-parser.js';
|
|
7
|
+
import { readPackageMetadata } from './generate/template.js';
|
|
8
|
+
import type { ToolMetadata } from './generate/tools.js';
|
|
9
|
+
import { extractHttpServerTarget } from './http-utils.js';
|
|
10
|
+
import { buildToolDoc } from './list-detail-helpers.js';
|
|
11
|
+
import { consumeOutputFormat } from './output-format.js';
|
|
12
|
+
import { findServerByHttpUrl } from './server-lookup.js';
|
|
13
|
+
import { loadToolMetadata } from './tool-cache.js';
|
|
14
|
+
|
|
15
|
+
interface EmitTsFlags {
|
|
16
|
+
server?: string;
|
|
17
|
+
outPath?: string;
|
|
18
|
+
mode: 'types' | 'client';
|
|
19
|
+
includeOptional: boolean;
|
|
20
|
+
typesOutPath?: string;
|
|
21
|
+
format: 'text' | 'json';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface ParsedEmitTsOptions extends Required<Omit<EmitTsFlags, 'server' | 'outPath' | 'typesOutPath'>> {
|
|
25
|
+
server: string;
|
|
26
|
+
outPath: string;
|
|
27
|
+
typesOutPath?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function handleEmitTs(runtime: Runtime, args: string[]): Promise<void> {
|
|
31
|
+
const options = parseEmitTsArgs(args);
|
|
32
|
+
const definition = getServerDefinition(runtime, options.server);
|
|
33
|
+
const metadataEntries = await loadToolMetadata(runtime, options.server, {
|
|
34
|
+
includeSchema: true,
|
|
35
|
+
autoAuthorize: false,
|
|
36
|
+
});
|
|
37
|
+
const generator = await readPackageMetadata();
|
|
38
|
+
const metadata: EmitMetadata = {
|
|
39
|
+
server: definition,
|
|
40
|
+
generatorLabel: `${generator.name}@${generator.version}`,
|
|
41
|
+
generatedAt: new Date(),
|
|
42
|
+
};
|
|
43
|
+
const docEntries = buildDocEntries(options.server, metadataEntries, options.includeOptional);
|
|
44
|
+
const interfaceName = buildInterfaceName(options.server);
|
|
45
|
+
|
|
46
|
+
if (options.mode === 'types') {
|
|
47
|
+
const source = renderTypesModule({ interfaceName, docs: docEntries, metadata });
|
|
48
|
+
await writeFile(options.outPath, source);
|
|
49
|
+
if (options.format === 'json') {
|
|
50
|
+
console.log(
|
|
51
|
+
JSON.stringify(
|
|
52
|
+
{
|
|
53
|
+
mode: 'types',
|
|
54
|
+
server: options.server,
|
|
55
|
+
outPath: options.outPath,
|
|
56
|
+
},
|
|
57
|
+
null,
|
|
58
|
+
2
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
} else {
|
|
62
|
+
console.log(`Emitted TypeScript definitions for ${options.server} → ${options.outPath}`);
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const typesOutPath = options.typesOutPath ?? deriveTypesOutPath(options.outPath);
|
|
68
|
+
const relativeImportPath = computeImportPath(options.outPath, typesOutPath);
|
|
69
|
+
const typesSource = renderTypesModule({ interfaceName, docs: docEntries, metadata });
|
|
70
|
+
const clientSource = renderClientModule({
|
|
71
|
+
interfaceName,
|
|
72
|
+
docs: docEntries,
|
|
73
|
+
metadata,
|
|
74
|
+
typesImportPath: relativeImportPath,
|
|
75
|
+
});
|
|
76
|
+
await writeFile(typesOutPath, typesSource);
|
|
77
|
+
await writeFile(options.outPath, clientSource);
|
|
78
|
+
if (options.format === 'json') {
|
|
79
|
+
console.log(
|
|
80
|
+
JSON.stringify(
|
|
81
|
+
{
|
|
82
|
+
mode: 'client',
|
|
83
|
+
server: options.server,
|
|
84
|
+
clientOutPath: options.outPath,
|
|
85
|
+
typesOutPath,
|
|
86
|
+
},
|
|
87
|
+
null,
|
|
88
|
+
2
|
|
89
|
+
)
|
|
90
|
+
);
|
|
91
|
+
} else {
|
|
92
|
+
console.log(`Emitted client + types for ${options.server} → ${options.outPath} / ${typesOutPath}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function parseEmitTsArgs(args: string[]): ParsedEmitTsOptions {
|
|
97
|
+
const flags: EmitTsFlags = {
|
|
98
|
+
mode: 'types',
|
|
99
|
+
includeOptional: false,
|
|
100
|
+
format: 'text',
|
|
101
|
+
};
|
|
102
|
+
const common = extractGeneratorFlags(args, { allowIncludeOptional: true });
|
|
103
|
+
if (common.includeOptional) {
|
|
104
|
+
flags.includeOptional = true;
|
|
105
|
+
}
|
|
106
|
+
flags.format = consumeOutputFormat(args, {
|
|
107
|
+
defaultFormat: 'text',
|
|
108
|
+
allowed: ['text', 'json'],
|
|
109
|
+
enableRawShortcut: false,
|
|
110
|
+
jsonShortcutFlag: '--json',
|
|
111
|
+
}) as EmitTsFlags['format'];
|
|
112
|
+
let index = 0;
|
|
113
|
+
while (index < args.length) {
|
|
114
|
+
const token = args[index];
|
|
115
|
+
if (!token) {
|
|
116
|
+
index += 1;
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (token === '--out') {
|
|
120
|
+
const value = args[index + 1];
|
|
121
|
+
if (!value) {
|
|
122
|
+
throw new Error("Flag '--out' requires a path.");
|
|
123
|
+
}
|
|
124
|
+
flags.outPath = value;
|
|
125
|
+
args.splice(index, 2);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (token === '--types-out') {
|
|
129
|
+
const value = args[index + 1];
|
|
130
|
+
if (!value) {
|
|
131
|
+
throw new Error("Flag '--types-out' requires a path.");
|
|
132
|
+
}
|
|
133
|
+
flags.typesOutPath = value;
|
|
134
|
+
args.splice(index, 2);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (token === '--mode') {
|
|
138
|
+
const value = args[index + 1];
|
|
139
|
+
if (value !== 'types' && value !== 'client') {
|
|
140
|
+
throw new Error("--mode must be 'types' or 'client'.");
|
|
141
|
+
}
|
|
142
|
+
flags.mode = value;
|
|
143
|
+
args.splice(index, 2);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (token.startsWith('--')) {
|
|
147
|
+
throw new Error(`Unknown flag '${token}' for emit-ts.`);
|
|
148
|
+
}
|
|
149
|
+
index += 1;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const server = args.shift();
|
|
153
|
+
if (!server) {
|
|
154
|
+
throw new Error('Usage: mcporter emit-ts <server> --out <file> [--mode types|client]');
|
|
155
|
+
}
|
|
156
|
+
const outPath = flags.outPath;
|
|
157
|
+
if (!outPath) {
|
|
158
|
+
throw new Error("Flag '--out' is required for emit-ts.");
|
|
159
|
+
}
|
|
160
|
+
if (flags.mode === 'client' && !outPath.endsWith('.ts')) {
|
|
161
|
+
throw new Error('--out should point to a .ts file when --mode client is used.');
|
|
162
|
+
}
|
|
163
|
+
if (flags.mode === 'types' && !outPath.endsWith('.ts') && !outPath.endsWith('.d.ts')) {
|
|
164
|
+
throw new Error('--out should be a .ts or .d.ts file for --mode types.');
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
server,
|
|
168
|
+
outPath: path.resolve(outPath),
|
|
169
|
+
mode: flags.mode,
|
|
170
|
+
includeOptional: flags.includeOptional,
|
|
171
|
+
typesOutPath: flags.typesOutPath ? path.resolve(flags.typesOutPath) : undefined,
|
|
172
|
+
format: flags.format,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function getServerDefinition(runtime: Runtime, selector: string): ServerDefinition {
|
|
177
|
+
try {
|
|
178
|
+
return runtime.getDefinition(selector);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
const resolved = resolveHttpServerName(runtime, selector);
|
|
181
|
+
if (resolved) {
|
|
182
|
+
return runtime.getDefinition(resolved);
|
|
183
|
+
}
|
|
184
|
+
if (error instanceof Error) {
|
|
185
|
+
throw new Error(error.message);
|
|
186
|
+
}
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function resolveHttpServerName(runtime: Runtime, selector: string): string | undefined {
|
|
192
|
+
const target = extractHttpServerTarget(selector);
|
|
193
|
+
if (!target) {
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
return findServerByHttpUrl(runtime.getDefinitions(), target);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function buildDocEntries(
|
|
200
|
+
serverName: string,
|
|
201
|
+
metadataEntries: ToolMetadata[],
|
|
202
|
+
includeOptional: boolean
|
|
203
|
+
): ToolDocEntry[] {
|
|
204
|
+
return metadataEntries.map((entry) => {
|
|
205
|
+
const doc = buildToolDoc({
|
|
206
|
+
serverName,
|
|
207
|
+
toolName: entry.tool.name,
|
|
208
|
+
description: entry.tool.description,
|
|
209
|
+
outputSchema: entry.tool.outputSchema,
|
|
210
|
+
options: entry.options,
|
|
211
|
+
requiredOnly: !includeOptional,
|
|
212
|
+
colorize: false,
|
|
213
|
+
defaultReturnType: 'CallResult',
|
|
214
|
+
});
|
|
215
|
+
return {
|
|
216
|
+
toolName: entry.tool.name,
|
|
217
|
+
methodName: entry.methodName,
|
|
218
|
+
doc,
|
|
219
|
+
};
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function buildInterfaceName(serverName: string): string {
|
|
224
|
+
const cleaned = serverName
|
|
225
|
+
.split(/[^A-Za-z0-9]+/)
|
|
226
|
+
.filter(Boolean)
|
|
227
|
+
.map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
|
|
228
|
+
.join('');
|
|
229
|
+
const base = cleaned.length > 0 ? cleaned : 'Server';
|
|
230
|
+
return `${base}Tools`;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function deriveTypesOutPath(tsPath: string): string {
|
|
234
|
+
const dir = path.dirname(tsPath);
|
|
235
|
+
const base = path.basename(tsPath, path.extname(tsPath));
|
|
236
|
+
return path.join(dir, `${base}.d.ts`);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
async function writeFile(targetPath: string, contents: string): Promise<void> {
|
|
240
|
+
await fs.mkdir(path.dirname(targetPath), { recursive: true });
|
|
241
|
+
await fs.writeFile(targetPath, `${contents}\n`, 'utf8');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function computeImportPath(fromPath: string, typesPath: string): string {
|
|
245
|
+
const fromDir = path.dirname(fromPath);
|
|
246
|
+
const relative = path.relative(fromDir, typesPath).replace(/\\/g, '/');
|
|
247
|
+
const withoutExt = relative.replace(/\.[^.]+$/, '');
|
|
248
|
+
if (withoutExt.startsWith('.')) {
|
|
249
|
+
return withoutExt;
|
|
250
|
+
}
|
|
251
|
+
return `./${withoutExt}`;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export const __test = {
|
|
255
|
+
parseEmitTsArgs,
|
|
256
|
+
buildInterfaceName,
|
|
257
|
+
deriveTypesOutPath,
|
|
258
|
+
computeImportPath,
|
|
259
|
+
buildDocEntries,
|
|
260
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import type { ServerDefinition } from '../config.js';
|
|
3
|
+
import type { ToolDocModel } from './list-detail-helpers.js';
|
|
4
|
+
|
|
5
|
+
export interface ToolDocEntry {
|
|
6
|
+
toolName: string;
|
|
7
|
+
methodName: string;
|
|
8
|
+
doc: ToolDocModel;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface EmitMetadata {
|
|
12
|
+
server: ServerDefinition;
|
|
13
|
+
generatorLabel: string;
|
|
14
|
+
generatedAt: Date;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface EmitTypesTemplateInput {
|
|
18
|
+
interfaceName: string;
|
|
19
|
+
docs: ToolDocEntry[];
|
|
20
|
+
metadata: EmitMetadata;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface EmitClientTemplateInput extends EmitTypesTemplateInput {
|
|
24
|
+
typesImportPath: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function renderTypesModule(input: EmitTypesTemplateInput): string {
|
|
28
|
+
const lines: string[] = [];
|
|
29
|
+
lines.push(...renderHeader(input.metadata));
|
|
30
|
+
lines.push("import type { CallResult } from '@nimrobo/mcporter-remote';");
|
|
31
|
+
lines.push('');
|
|
32
|
+
lines.push(`export interface ${input.interfaceName} {`);
|
|
33
|
+
input.docs.forEach((entry, index) => {
|
|
34
|
+
lines.push(...renderDocComment(entry.doc.docLines, ' '));
|
|
35
|
+
const methodSignature = toInterfaceSignature(entry.doc.tsSignature, { wrapInPromise: true });
|
|
36
|
+
lines.push(` ${methodSignature}`);
|
|
37
|
+
if (entry.doc.optionalSummary) {
|
|
38
|
+
lines.push(` // ${entry.doc.optionalSummary.replace(/^\/\//, '').trim()}`);
|
|
39
|
+
}
|
|
40
|
+
if (index !== input.docs.length - 1) {
|
|
41
|
+
lines.push('');
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (input.docs.length === 0) {
|
|
45
|
+
lines.push(' // No tools reported for this server.');
|
|
46
|
+
}
|
|
47
|
+
lines.push('}');
|
|
48
|
+
lines.push('');
|
|
49
|
+
return lines.join('\n');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function renderClientModule(input: EmitClientTemplateInput): string {
|
|
53
|
+
const lines: string[] = [];
|
|
54
|
+
lines.push(...renderHeader(input.metadata));
|
|
55
|
+
lines.push("import { createRuntime, createServerProxy, wrapCallResult } from '@nimrobo/mcporter-remote';");
|
|
56
|
+
lines.push(`import type { ${input.interfaceName} } from '${input.typesImportPath}';`);
|
|
57
|
+
lines.push('');
|
|
58
|
+
lines.push('type RuntimeInstance = Awaited<ReturnType<typeof createRuntime>>;');
|
|
59
|
+
const clientType = `${input.interfaceName.replace(/Tools$/, 'Client')}`;
|
|
60
|
+
const factoryName = `create${input.interfaceName.replace(/Tools$/, '')}Client`;
|
|
61
|
+
const serverName = input.metadata.server.name;
|
|
62
|
+
lines.push(`export type ${clientType} = ${input.interfaceName} & { close(): Promise<void> };`);
|
|
63
|
+
lines.push('');
|
|
64
|
+
lines.push('export interface CreateClientOptions {');
|
|
65
|
+
lines.push(' runtime?: RuntimeInstance;');
|
|
66
|
+
lines.push(' configPath?: string;');
|
|
67
|
+
lines.push(' rootDir?: string;');
|
|
68
|
+
lines.push('}');
|
|
69
|
+
lines.push('');
|
|
70
|
+
lines.push(`export async function ${factoryName}(options: CreateClientOptions = {}): Promise<${clientType}> {`);
|
|
71
|
+
lines.push(' const runtime = options.runtime ?? (await createRuntime({');
|
|
72
|
+
lines.push(' configPath: options.configPath,');
|
|
73
|
+
lines.push(' rootDir: options.rootDir,');
|
|
74
|
+
lines.push(' }));');
|
|
75
|
+
lines.push(' const ownsRuntime = !options.runtime;');
|
|
76
|
+
lines.push(` const proxy = createServerProxy(runtime, ${JSON.stringify(serverName)});`);
|
|
77
|
+
lines.push(` const client: ${clientType} = {`);
|
|
78
|
+
input.docs.forEach((entry, _index) => {
|
|
79
|
+
const methodName = entry.doc.tsSignature.match(/^function\s+([^()]+)/)?.[1] ?? entry.toolName;
|
|
80
|
+
lines.push(` async ${methodName}(params: Parameters<${input.interfaceName}['${methodName}']>[0]) {`);
|
|
81
|
+
lines.push(
|
|
82
|
+
` const tool = proxy.${entry.methodName} as (args: Parameters<${input.interfaceName}['${methodName}']>[0]) => Promise<unknown>;`
|
|
83
|
+
);
|
|
84
|
+
lines.push(' const raw = await tool(params);');
|
|
85
|
+
lines.push(' return wrapCallResult(raw).callResult;');
|
|
86
|
+
lines.push(' },');
|
|
87
|
+
lines.push('');
|
|
88
|
+
});
|
|
89
|
+
lines.push(' async close() {');
|
|
90
|
+
lines.push(' if (ownsRuntime) {');
|
|
91
|
+
lines.push(` await runtime.close(${JSON.stringify(serverName)}).catch(() => {});`);
|
|
92
|
+
lines.push(' }');
|
|
93
|
+
lines.push(' },');
|
|
94
|
+
lines.push(' };');
|
|
95
|
+
lines.push(' return client;');
|
|
96
|
+
lines.push('}');
|
|
97
|
+
lines.push('');
|
|
98
|
+
return lines.join('\n');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function renderHeader(metadata: EmitMetadata): string[] {
|
|
102
|
+
const lines: string[] = [];
|
|
103
|
+
const timestamp = metadata.generatedAt.toISOString();
|
|
104
|
+
lines.push(`// Generated on ${timestamp} by ${metadata.generatorLabel}`);
|
|
105
|
+
if (metadata.server.description) {
|
|
106
|
+
lines.push(`// Server: ${metadata.server.name} — ${metadata.server.description}`);
|
|
107
|
+
} else {
|
|
108
|
+
lines.push(`// Server: ${metadata.server.name}`);
|
|
109
|
+
}
|
|
110
|
+
const source = describeSource(metadata.server);
|
|
111
|
+
if (source) {
|
|
112
|
+
lines.push(`// Source: ${source}`);
|
|
113
|
+
}
|
|
114
|
+
const transport = describeTransport(metadata.server);
|
|
115
|
+
if (transport) {
|
|
116
|
+
lines.push(`// Transport: ${transport}`);
|
|
117
|
+
}
|
|
118
|
+
lines.push('');
|
|
119
|
+
return lines;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function renderDocComment(docLines: string[] | undefined, indent: string): string[] {
|
|
123
|
+
if (!docLines || docLines.length === 0) {
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
return docLines.map((line) => `${indent}${line}`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function toInterfaceSignature(signature: string, options?: { wrapInPromise?: boolean }): string {
|
|
130
|
+
const trimmed = signature.trim();
|
|
131
|
+
const match = trimmed.match(/^function\s+([^(]+)\((.*)\)\s*(?::\s*([^;]+))?;?$/);
|
|
132
|
+
if (!match) {
|
|
133
|
+
return trimmed.replace(/^function\s+/, '');
|
|
134
|
+
}
|
|
135
|
+
const [, name, params, returnTypeRaw] = match;
|
|
136
|
+
const returnType = (returnTypeRaw ?? 'void').trim();
|
|
137
|
+
const finalReturn = options?.wrapInPromise ? `Promise<${returnType}>` : returnType;
|
|
138
|
+
return `${name}(${params}): ${finalReturn};`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function describeTransport(definition: ServerDefinition): string | undefined {
|
|
142
|
+
if (definition.command.kind === 'http') {
|
|
143
|
+
const url = definition.command.url instanceof URL ? definition.command.url.href : String(definition.command.url);
|
|
144
|
+
return `HTTP ${url}`;
|
|
145
|
+
}
|
|
146
|
+
if (definition.command.kind === 'stdio') {
|
|
147
|
+
const cmd = [definition.command.command, ...(definition.command.args ?? [])].join(' ').trim();
|
|
148
|
+
return cmd.length > 0 ? `STDIO ${cmd}` : 'STDIO';
|
|
149
|
+
}
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function describeSource(definition: ServerDefinition): string | undefined {
|
|
154
|
+
if (definition.source?.kind === 'import') {
|
|
155
|
+
return path.normalize(definition.source.path);
|
|
156
|
+
}
|
|
157
|
+
if (definition.source?.kind === 'local') {
|
|
158
|
+
return definition.source.path;
|
|
159
|
+
}
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { EphemeralServerSpec } from './adhoc-server.js';
|
|
2
|
+
|
|
3
|
+
interface ExtractOptions {
|
|
4
|
+
allowPersist?: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// extractEphemeralServerFlags scans argv for ad-hoc server descriptors (HTTP/STDIO/env/etc.)
|
|
8
|
+
// and removes them so higher-level parsers can focus on command-specific flags.
|
|
9
|
+
export function extractEphemeralServerFlags(
|
|
10
|
+
args: string[],
|
|
11
|
+
options: ExtractOptions = {}
|
|
12
|
+
): EphemeralServerSpec | undefined {
|
|
13
|
+
let spec: EphemeralServerSpec | undefined;
|
|
14
|
+
const ensureSpec = (): EphemeralServerSpec => {
|
|
15
|
+
if (!spec) {
|
|
16
|
+
spec = {};
|
|
17
|
+
}
|
|
18
|
+
return spec;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const allowPersist = options.allowPersist ?? true;
|
|
22
|
+
let index = 0;
|
|
23
|
+
while (index < args.length) {
|
|
24
|
+
const token = args[index];
|
|
25
|
+
if (!token) {
|
|
26
|
+
index += 1;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (token === '--http-url' || token === '--sse') {
|
|
31
|
+
const value = args[index + 1];
|
|
32
|
+
if (!value) {
|
|
33
|
+
throw new Error("Flag '--http-url' requires a value.");
|
|
34
|
+
}
|
|
35
|
+
ensureSpec().httpUrl = value;
|
|
36
|
+
args.splice(index, 2);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (token === '--allow-http' || token === '--insecure') {
|
|
41
|
+
ensureSpec().allowInsecureHttp = true;
|
|
42
|
+
args.splice(index, 1);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (token === '--stdio') {
|
|
47
|
+
const value = args[index + 1];
|
|
48
|
+
if (!value) {
|
|
49
|
+
throw new Error("Flag '--stdio' requires a value.");
|
|
50
|
+
}
|
|
51
|
+
ensureSpec().stdioCommand = value;
|
|
52
|
+
args.splice(index, 2);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (token === '--stdio-arg') {
|
|
57
|
+
const value = args[index + 1];
|
|
58
|
+
if (!value) {
|
|
59
|
+
throw new Error("Flag '--stdio-arg' requires a value.");
|
|
60
|
+
}
|
|
61
|
+
const current = ensureSpec();
|
|
62
|
+
current.stdioArgs = [...(current.stdioArgs ?? []), value];
|
|
63
|
+
args.splice(index, 2);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (token === '--env') {
|
|
68
|
+
const value = args[index + 1];
|
|
69
|
+
if (!value || !value.includes('=')) {
|
|
70
|
+
throw new Error("Flag '--env' requires KEY=value.");
|
|
71
|
+
}
|
|
72
|
+
const [key, ...rest] = value.split('=');
|
|
73
|
+
if (!key) {
|
|
74
|
+
throw new Error("Flag '--env' requires KEY=value.");
|
|
75
|
+
}
|
|
76
|
+
const current = ensureSpec();
|
|
77
|
+
const envMap = current.env ? { ...current.env } : {};
|
|
78
|
+
envMap[key] = rest.join('=');
|
|
79
|
+
current.env = envMap;
|
|
80
|
+
args.splice(index, 2);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (token === '--cwd') {
|
|
85
|
+
const value = args[index + 1];
|
|
86
|
+
if (!value) {
|
|
87
|
+
throw new Error("Flag '--cwd' requires a value.");
|
|
88
|
+
}
|
|
89
|
+
ensureSpec().cwd = value;
|
|
90
|
+
args.splice(index, 2);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (token === '--name') {
|
|
95
|
+
const value = args[index + 1];
|
|
96
|
+
if (!value) {
|
|
97
|
+
throw new Error("Flag '--name' requires a value.");
|
|
98
|
+
}
|
|
99
|
+
ensureSpec().name = value;
|
|
100
|
+
args.splice(index, 2);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (token === '--description') {
|
|
105
|
+
const value = args[index + 1];
|
|
106
|
+
if (!value) {
|
|
107
|
+
throw new Error("Flag '--description' requires a value.");
|
|
108
|
+
}
|
|
109
|
+
ensureSpec().description = value;
|
|
110
|
+
args.splice(index, 2);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (allowPersist && token === '--persist') {
|
|
115
|
+
const value = args[index + 1];
|
|
116
|
+
if (!value) {
|
|
117
|
+
throw new Error("Flag '--persist' requires a value.");
|
|
118
|
+
}
|
|
119
|
+
ensureSpec().persistPath = value;
|
|
120
|
+
args.splice(index, 2);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
index += 1;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return spec;
|
|
128
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { Runtime } from '../runtime.js';
|
|
2
|
+
import {
|
|
3
|
+
type EphemeralServerResolution,
|
|
4
|
+
type EphemeralServerSpec,
|
|
5
|
+
persistEphemeralServer,
|
|
6
|
+
resolveEphemeralServer,
|
|
7
|
+
splitCommandLine,
|
|
8
|
+
} from './adhoc-server.js';
|
|
9
|
+
import { looksLikeHttpUrl, normalizeHttpUrlCandidate } from './http-utils.js';
|
|
10
|
+
import { findServerByHttpUrl } from './server-lookup.js';
|
|
11
|
+
|
|
12
|
+
interface PrepareEphemeralServerTargetOptions {
|
|
13
|
+
runtime: Runtime;
|
|
14
|
+
target?: string;
|
|
15
|
+
ephemeral?: EphemeralServerSpec;
|
|
16
|
+
nameHints?: string[];
|
|
17
|
+
reuseFromSpec?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface PrepareEphemeralServerTargetResult {
|
|
21
|
+
target?: string;
|
|
22
|
+
resolution?: EphemeralServerResolution;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function prepareEphemeralServerTarget(
|
|
26
|
+
options: PrepareEphemeralServerTargetOptions
|
|
27
|
+
): Promise<PrepareEphemeralServerTargetResult> {
|
|
28
|
+
let target = options.target;
|
|
29
|
+
let spec = options.ephemeral ? { ...options.ephemeral } : undefined;
|
|
30
|
+
|
|
31
|
+
const promoteUrlCandidate = (value: string | undefined): string | undefined => {
|
|
32
|
+
if (!value) {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
const normalized = normalizeHttpUrlCandidate(value);
|
|
36
|
+
if (!normalized) {
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
const reused = findServerByHttpUrl(options.runtime.getDefinitions(), normalized);
|
|
40
|
+
if (reused) {
|
|
41
|
+
return reused;
|
|
42
|
+
}
|
|
43
|
+
if (!spec) {
|
|
44
|
+
spec = { httpUrl: normalized };
|
|
45
|
+
} else if (!spec.httpUrl) {
|
|
46
|
+
spec = { ...spec, httpUrl: normalized };
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
target = promoteUrlCandidate(target);
|
|
52
|
+
|
|
53
|
+
if (!spec) {
|
|
54
|
+
const inferredInline = inferInlineStdioSpec(target);
|
|
55
|
+
if (inferredInline) {
|
|
56
|
+
spec = inferredInline;
|
|
57
|
+
target = undefined;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (spec) {
|
|
62
|
+
applyNameHints(spec, options.nameHints);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!spec) {
|
|
66
|
+
return { target };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (spec.httpUrl) {
|
|
70
|
+
const normalized = normalizeHttpUrlCandidate(spec.httpUrl);
|
|
71
|
+
if (normalized) {
|
|
72
|
+
spec = { ...spec, httpUrl: normalized };
|
|
73
|
+
if (options.reuseFromSpec) {
|
|
74
|
+
const reused = findServerByHttpUrl(options.runtime.getDefinitions(), normalized);
|
|
75
|
+
if (reused) {
|
|
76
|
+
return { target: reused };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const resolution = resolveEphemeralServer(spec);
|
|
83
|
+
options.runtime.registerDefinition(resolution.definition, { overwrite: true });
|
|
84
|
+
if (spec.persistPath) {
|
|
85
|
+
await persistEphemeralServer(resolution, spec.persistPath);
|
|
86
|
+
}
|
|
87
|
+
const resolvedTarget = target ?? resolution.name;
|
|
88
|
+
return { target: resolvedTarget, resolution };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function applyNameHints(spec: EphemeralServerSpec | undefined, hints: string[] | undefined): void {
|
|
92
|
+
if (!spec || spec.name || !hints) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
for (const hint of hints) {
|
|
96
|
+
if (!hint) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (looksLikeHttpUrl(hint)) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
spec.name = hint;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function inferInlineStdioSpec(target: string | undefined): EphemeralServerSpec | undefined {
|
|
108
|
+
if (!target) {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
const trimmed = target.trim();
|
|
112
|
+
if (!trimmed) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
if (looksLikeHttpUrl(trimmed)) {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
if (!trimmed.includes(' ')) {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
const parts = splitCommandLine(trimmed);
|
|
123
|
+
if (parts.length < 2) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
const executable = parts[0]?.split(/[\\/]/).pop();
|
|
127
|
+
if (executable !== 'npx') {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
return { stdioCommand: trimmed };
|
|
131
|
+
} catch {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
}
|