@h-ai/deploy 1.0.0-beta.5 → 1.0.0-beta.6

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/dist/index.d.ts CHANGED
@@ -375,100 +375,6 @@ type DeployConfig = z.infer<typeof DeployConfigSchema>;
375
375
  */
376
376
  type DeployConfigInput = z.input<typeof DeployConfigSchema>;
377
377
 
378
- /** 部署环境的加载和持久化;公开环境文件不保存真实凭据。 */
379
-
380
- /**
381
- * 部署环境快照;例如 prod 的 targetValues 只来自 `.env.prod`,不包含基础/私有覆盖。
382
- * @example
383
- * ```ts
384
- * import type { DeploymentEnvironment } from '@h-ai/deploy'
385
- * const environment: DeploymentEnvironment = { environment: 'prod', envDir: '/workspace/shop', values: { HAI_DB_TYPE: 'postgresql' }, targetValues: { HAI_DB_TYPE: 'postgresql' } }
386
- * // values 可能还含私有凭据,不能整体写入日志。
387
- * ```
388
- */
389
- interface DeploymentEnvironment {
390
- /** 文件模式(dev/test/prod 或其他合法模式名)。 */
391
- environment: string;
392
- /** 环境文件的绝对目录。 */
393
- envDir: string;
394
- /** 合并后的部署变量,可能含私有值,不得直接记录日志。 */
395
- values: Record<string, string>;
396
- /** 仅目标环境文件显式声明的变量,用于判断能否“保持不变”。 */
397
- targetValues: Record<string, string>;
398
- }
399
- /**
400
- * 按来源归并环境变量;HAI 高层父配置清除旧叶,同层按父→叶处理。
401
- * @param layers - 从低到高优先级的环境来源。
402
- * @param prefix - 可选变量前缀,仅归并该模块。
403
- * @returns 归并后的字面量环境变量,可能包含秘密。
404
- * @example 模块内部上下文
405
- * ```ts
406
- * const env = mergeEnvironmentLayers([{ HAI_CACHE_TYPE: 'memory' }, { HAI_CACHE: '{"type":"redis"}' }])
407
- * ```
408
- */
409
- declare function mergeEnvironmentLayers(layers: Array<Record<string, string | undefined>>, prefix?: string): Record<string, string>;
410
- /**
411
- * 按部署环境解析配置;未选择的可选 Provisioner 缺少凭据时保留空值,选择完成后由 Schema 校验。
412
- * hai.json 只读取对应的根分区;运行时模块继续读取 YAML。不修改 core 缓存或进程变量。
413
- * @param name - 模块配置名,例如 deploy/db/iam
414
- * @param path - hai.json 或运行时 YAML 文件的绝对路径
415
- * @param values - 已加载的目标环境变量
416
- * @returns 配置对象;解析错误已脱敏
417
- * @example
418
- * ```ts
419
- * import { loadDeploymentConfig, loadDeploymentEnvironment } from '@h-ai/deploy'
420
- * const environment = loadDeploymentEnvironment({ environment: 'prod', envDir: process.cwd() })
421
- * if (!environment.success) throw new Error(environment.error.message)
422
- * const config = loadDeploymentConfig('deploy', `${process.cwd()}/hai.json`, environment.data.values)
423
- * if (!config.success) throw new Error(config.error.message)
424
- * // 返回对象仍需经 DeployConfigSchema 或 deploy.init 验证。
425
- * ```
426
- */
427
- declare function loadDeploymentConfig(name: string, path: string, values: Record<string, string | undefined>): HaiResult<Record<string, unknown>>;
428
- /**
429
- * 加载部署环境;指定环境文件缺失时返回错误并要求用户创建。
430
- * 部署目标按进程 > 模式私有 > 模式公共 > 旧全局私有 > 基础归并。
431
- * 其它模块保留进程 > 模式私有 > 旧全局私有 > 模式公共 > 基础;targetValues 仅记录模式公共项。
432
- * @param options - 模式、环境目录与是否强制存在目标文件
433
- * @param options.environment - dev/test/prod 或自定义模式
434
- * @param options.envDir - 环境文件所在目录
435
- * @param options.requireFile - 默认 true;扫描无显式环境时可只读取已有基础文件
436
- * @returns 环境快照,可能包含私有值,不得直接输出
437
- * @example
438
- * ```ts
439
- * import { loadDeploymentEnvironment } from '@h-ai/deploy'
440
- * const loaded = loadDeploymentEnvironment({ environment: 'prod', envDir: process.cwd() })
441
- * if (!loaded.success) throw new Error(loaded.error.message)
442
- * const explicitlyConfigured = loaded.data.targetValues.HAI_DB_TYPE
443
- * ```
444
- */
445
- declare function loadDeploymentEnvironment(options: {
446
- environment: string;
447
- envDir: string;
448
- requireFile?: boolean;
449
- }): HaiResult<DeploymentEnvironment>;
450
- /**
451
- * 保存部署变量:公共值写目标环境文件,凭据写 `.env.<environment>.local`;旧共享私有文件不删除。
452
- * 返回实际写入的变量名,调用者只展示名称或脱敏值。
453
- * @param environment - 已加载的目标环境快照
454
- * @param values - 需要更新的变量;未提供的项保持原状
455
- * @param options - private 为 true 时所有值只保存在本机;适用于 SSH 地址、端口及密钥路径
456
- * @param options.private - 是否将全部值保存到选中模式的私有文件
457
- * @returns 已保存的变量名或脱敏错误
458
- * @example
459
- * ```ts
460
- * import { loadDeploymentEnvironment, saveDeploymentEnvironment } from '@h-ai/deploy'
461
- * const loaded = loadDeploymentEnvironment({ environment: 'prod', envDir: process.cwd() })
462
- * if (!loaded.success) throw new Error(loaded.error.message)
463
- * const saved = saveDeploymentEnvironment(loaded.data, { HAI_DB_HOST: 'db' })
464
- * if (!saved.success) throw new Error(saved.error.message)
465
- * // 密钥应以 { private: true } 写入被忽略的 .env.prod.local,不能放公共环境文件。
466
- * ```
467
- */
468
- declare function saveDeploymentEnvironment(environment: DeploymentEnvironment, values: Record<string, string>, options?: {
469
- private?: boolean;
470
- }): HaiResult<string[]>;
471
-
472
378
  /**
473
379
  *
474
380
  * @example
@@ -722,6 +628,10 @@ interface DeployCommandState {
722
628
  * ```
723
629
  */
724
630
  interface DeployAppOptions {
631
+ /** 本地打包所需镜像的下载源;Compose 与部署身份保留原始镜像引用。 */
632
+ imageSource?: ImageSourceConfig;
633
+ /** 本次拉取子进程的代理;远程 Podman/Docker daemon 的代理需在引擎侧设置。 */
634
+ proxy?: DownloadProxyConfig;
725
635
  /** 接收实际执行阶段,用于终端进度显示;不包含凭据或配置原文。 */
726
636
  onProgress?: (stage: 'packaging' | 'preflight' | 'images' | 'dependencies' | 'start' | 'https' | 'health' | 'complete') => void;
727
637
  /** 只更新指定的 Compose 服务;省略时完整制品部署全部,部分制品只部署其镜像。 */
@@ -743,6 +653,31 @@ interface DeployAppOptions {
743
653
  /** 交付包命名路径;默认在 .hai/deploy/<环境>/bundle-<项目>-<部署ID>-<版本>/ 中输出同名 tar 和脚本,自定义 release.tar 输出 release-<版本>/release-<版本>.tar;已有目录拒绝覆盖。 */
744
654
  output?: string;
745
655
  }
656
+ /**
657
+ * 镜像下载源;自定义映射可带命名空间路径,不含认证信息。
658
+ * @example
659
+ * ```ts
660
+ * import type { ImageSourceConfig } from '@h-ai/deploy'
661
+ * const source: ImageSourceConfig = { type: 'custom', registries: { 'docker.io': 'mirror.example.com/docker.io', 'ghcr.io': 'mirror.example.com/ghcr.io' } }
662
+ * ```
663
+ */
664
+ interface ImageSourceConfig {
665
+ type: 'official' | 'cn' | 'custom';
666
+ registries?: Record<string, string>;
667
+ }
668
+ /**
669
+ * 下载代理;自定义地址仅接受无认证的 HTTP(S),认证代理从进程环境继承。
670
+ * @example
671
+ * ```ts
672
+ * import type { DownloadProxyConfig } from '@h-ai/deploy'
673
+ * const proxy: DownloadProxyConfig = { mode: 'custom', url: 'http://127.0.0.1:10808', bypass: 'localhost,127.0.0.1' }
674
+ * ```
675
+ */
676
+ interface DownloadProxyConfig {
677
+ mode: 'inherit' | 'system' | 'custom' | 'none';
678
+ url?: string;
679
+ bypass?: string;
680
+ }
746
681
  /**
747
682
  * Deploy 凭证文件操作。
748
683
  *
@@ -929,6 +864,131 @@ interface DeployFunctions {
929
864
  deployApp: (appDir: string, options?: DeployAppOptions) => Promise<HaiResult<DeployResult>>;
930
865
  }
931
866
 
867
+ /** 构建与交付共用的下载源解析;不修改系统或容器引擎配置。 */
868
+
869
+ /**
870
+ * 将镜像引用映射到所选下载源,保留命名空间、版本与摘要。
871
+ * @param reference - Docker/OCI 镜像引用。
872
+ * @param source - 官方、大陆或按原仓库配置的自定义源。
873
+ * @returns 下载引用;官方源保留输入引用。
874
+ * @throws Error - 源、仓库映射或镜像引用不合法。
875
+ * @example
876
+ * ```ts
877
+ * import { resolveImageReference } from '@h-ai/deploy'
878
+ * const image = resolveImageReference('node:24.22.1-bookworm-slim', { type: 'cn' })
879
+ * // docker.1ms.run/library/node:24.22.1-bookworm-slim
880
+ * ```
881
+ */
882
+ declare function resolveImageReference(reference: string, source?: ImageSourceConfig): string;
883
+ /**
884
+ * 解析本次下载使用的代理环境,不写配置、不重启引擎。
885
+ * @param config - 继承进程、读取系统、自定义或禁用代理。
886
+ * @returns 显式覆盖大小写代理变量的环境;远程引擎仍需自身配置代理。
887
+ * @throws Error - 配置非法、系统仅提供 PAC 或平台不支持读取系统代理。
888
+ * @example
889
+ * ```ts
890
+ * import { resolveDownloadProxy } from '@h-ai/deploy'
891
+ * const environment = resolveDownloadProxy({ mode: 'custom', url: 'http://127.0.0.1:10808' })
892
+ * // environment.HTTPS_PROXY 供本次子进程使用,不写进运行镜像。
893
+ * ```
894
+ */
895
+ declare function resolveDownloadProxy(config?: DownloadProxyConfig): Record<string, string>;
896
+
897
+ /** 部署环境的加载和持久化;公开环境文件不保存真实凭据。 */
898
+
899
+ /**
900
+ * 部署环境快照;例如 prod 的 targetValues 只来自 `.env.prod`,不包含基础/私有覆盖。
901
+ * @example
902
+ * ```ts
903
+ * import type { DeploymentEnvironment } from '@h-ai/deploy'
904
+ * const environment: DeploymentEnvironment = { environment: 'prod', envDir: '/workspace/shop', values: { HAI_DB_TYPE: 'postgresql' }, targetValues: { HAI_DB_TYPE: 'postgresql' } }
905
+ * // values 可能还含私有凭据,不能整体写入日志。
906
+ * ```
907
+ */
908
+ interface DeploymentEnvironment {
909
+ /** 文件模式(dev/test/prod 或其他合法模式名)。 */
910
+ environment: string;
911
+ /** 环境文件的绝对目录。 */
912
+ envDir: string;
913
+ /** 合并后的部署变量,可能含私有值,不得直接记录日志。 */
914
+ values: Record<string, string>;
915
+ /** 仅目标环境文件显式声明的变量,用于判断能否“保持不变”。 */
916
+ targetValues: Record<string, string>;
917
+ }
918
+ /**
919
+ * 按来源归并环境变量;HAI 高层父配置清除旧叶,同层按父→叶处理。
920
+ * @param layers - 从低到高优先级的环境来源。
921
+ * @param prefix - 可选变量前缀,仅归并该模块。
922
+ * @returns 归并后的字面量环境变量,可能包含秘密。
923
+ * @example 模块内部上下文
924
+ * ```ts
925
+ * const env = mergeEnvironmentLayers([{ HAI_CACHE_TYPE: 'memory' }, { HAI_CACHE: '{"type":"redis"}' }])
926
+ * ```
927
+ */
928
+ declare function mergeEnvironmentLayers(layers: Array<Record<string, string | undefined>>, prefix?: string): Record<string, string>;
929
+ /**
930
+ * 按部署环境解析配置;未选择的可选 Provisioner 缺少凭据时保留空值,选择完成后由 Schema 校验。
931
+ * hai.json 只读取对应的根分区;运行时模块继续读取 YAML。不修改 core 缓存或进程变量。
932
+ * @param name - 模块配置名,例如 deploy/db/iam
933
+ * @param path - hai.json 或运行时 YAML 文件的绝对路径
934
+ * @param values - 已加载的目标环境变量
935
+ * @returns 配置对象;解析错误已脱敏
936
+ * @example
937
+ * ```ts
938
+ * import { loadDeploymentConfig, loadDeploymentEnvironment } from '@h-ai/deploy'
939
+ * const environment = loadDeploymentEnvironment({ environment: 'prod', envDir: process.cwd() })
940
+ * if (!environment.success) throw new Error(environment.error.message)
941
+ * const config = loadDeploymentConfig('deploy', `${process.cwd()}/hai.json`, environment.data.values)
942
+ * if (!config.success) throw new Error(config.error.message)
943
+ * // 返回对象仍需经 DeployConfigSchema 或 deploy.init 验证。
944
+ * ```
945
+ */
946
+ declare function loadDeploymentConfig(name: string, path: string, values: Record<string, string | undefined>): HaiResult<Record<string, unknown>>;
947
+ /**
948
+ * 加载部署环境;指定环境文件缺失时返回错误并要求用户创建。
949
+ * 统一按进程 > 模式私有 > 全局私有 > 模式公共 > 基础归并;targetValues 仅记录模式公共项。
950
+ * @param options - 模式、环境目录与是否强制存在目标文件
951
+ * @param options.environment - dev/test/prod 或自定义模式
952
+ * @param options.envDir - 环境文件所在目录
953
+ * @param options.requireFile - 默认 true;扫描无显式环境时可只读取已有基础文件
954
+ * @returns 环境快照,可能包含私有值,不得直接输出
955
+ * @example
956
+ * ```ts
957
+ * import { loadDeploymentEnvironment } from '@h-ai/deploy'
958
+ * const loaded = loadDeploymentEnvironment({ environment: 'prod', envDir: process.cwd() })
959
+ * if (!loaded.success) throw new Error(loaded.error.message)
960
+ * const explicitlyConfigured = loaded.data.targetValues.HAI_DB_TYPE
961
+ * ```
962
+ */
963
+ declare function loadDeploymentEnvironment(options: {
964
+ environment: string;
965
+ envDir: string;
966
+ requireFile?: boolean;
967
+ }): HaiResult<DeploymentEnvironment>;
968
+ /**
969
+ * 保存部署变量:公共值写目标环境文件,凭据写 `.env.<environment>.local`;旧共享私有文件不删除。
970
+ * 返回实际写入的变量名,调用者只展示名称或脱敏值。
971
+ * @param environment - 已加载的目标环境快照
972
+ * @param values - 需要更新的变量;未提供的项保持原状
973
+ * @param options - private 为 true 时所有值只保存在本机;适用于 SSH 地址、端口及密钥路径
974
+ * @param options.private - 是否将全部值保存到选中模式的私有文件
975
+ * @param options.replace - 本次完整替换的配置前缀,只清理该模式中对应项。
976
+ * @returns 已保存的变量名或脱敏错误
977
+ * @example
978
+ * ```ts
979
+ * import { loadDeploymentEnvironment, saveDeploymentEnvironment } from '@h-ai/deploy'
980
+ * const loaded = loadDeploymentEnvironment({ environment: 'prod', envDir: process.cwd() })
981
+ * if (!loaded.success) throw new Error(loaded.error.message)
982
+ * const saved = saveDeploymentEnvironment(loaded.data, { HAI_DB_HOST: 'db' })
983
+ * if (!saved.success) throw new Error(saved.error.message)
984
+ * // 密钥应以 { private: true } 写入被忽略的 .env.prod.local,不能放公共环境文件。
985
+ * ```
986
+ */
987
+ declare function saveDeploymentEnvironment(environment: DeploymentEnvironment, values: Record<string, unknown>, options?: {
988
+ private?: boolean;
989
+ replace?: readonly string[];
990
+ }): HaiResult<string[]>;
991
+
932
992
  /**
933
993
  * @h-ai/deploy — 部署辅助函数
934
994
  *
@@ -1002,7 +1062,7 @@ declare const deploy: DeployFunctions;
1002
1062
  * const message = deployM('deploy_sshRequired')
1003
1063
  * ```
1004
1064
  */
1005
- declare const deployM: (key: "deploy_notInitialized" | "deploy_initFailed" | "deploy_unsupportedProviderType" | "deploy_unsupportedProvisionerType" | "deploy_configTokenRequired" | "deploy_authRequired" | "deploy_authFailed" | "deploy_projectCreateFailed" | "deploy_uploadFailed" | "deploy_deployFailed" | "deploy_provisionFailed" | "deploy_adapterMissing" | "deploy_scanFailed" | "deploy_envVarFailed" | "deploy_credentialError" | "deploy_credentialInvalidKey" | "deploy_credentialSaved" | "deploy_credentialLoaded" | "deploy_configError" | "deploy_credentialMissing" | "deploy_apiError" | "deploy_fileUploadFailed" | "deploy_provisionNoResult" | "deploy_recoveryFailure" | "deploy_recoverySuggestion" | "deploy_commandTimeout" | "deploy_commandFailed" | "deploy_remoteConnectFailed" | "deploy_remoteRuntimeMissing" | "deploy_imageTransferFailed" | "deploy_healthCheckFailed" | "deploy_invalidEnvironment" | "deploy_environmentMissing" | "deploy_environmentReadFailed" | "deploy_environmentWriteFailed" | "deploy_multipleApplications" | "deploy_purposeSqlite" | "deploy_purposeDatabase" | "deploy_purposeMemory" | "deploy_purposeLocal" | "deploy_purposeCache" | "deploy_purposeStorage" | "deploy_purposeVector" | "deploy_purposeDisabled" | "deploy_purposeLdap" | "deploy_purposeConsole" | "deploy_purposeEmail" | "deploy_purposeSms" | "deploy_webProxyInvalid" | "deploy_webBaseConflict" | "deploy_storageProxyInvalid" | "deploy_storagePublicEndpointInvalid" | "deploy_storageBackendRequired" | "deploy_artifactInvalid" | "deploy_sshRequired" | "deploy_sshPasswordInvalid" | "deploy_sshAskpassFailed" | "deploy_sshAskpassCleanupFailed" | "deploy_targetAuth" | "deploy_targetPasswordEnv" | "deploy_bundleInstructions" | "deploy_bundleMetadata" | "deploy_targetHost" | "deploy_targetPort" | "deploy_targetUsername" | "deploy_targetIdentityFile" | "deploy_targetKnownHostsFile" | "deploy_targetStrictHostKeyChecking" | "deploy_targetConnectTimeoutSeconds" | "deploy_targetDirectory" | "deploy_targetBundle" | "deploy_bundleOnlyContainer" | "deploy_selectedContainerOnly" | "deploy_selectionInvalid" | "deploy_imageVersionRequired" | "deploy_bundleRuntimeRequired" | "deploy_bundleFailed" | "deploy_configFileInvalid" | "deploy_configFileUnreadable" | "deploy_bundleNameInvalid" | "deploy_localStopped" | "deploy_localUnknown" | "deploy_localNotStarted" | "deploy_commandOutputFailed" | "deploy_commandInputFailed" | "deploy_commandTreeActive" | "deploy_commandExecutionFailed" | "deploy_remoteUnknown" | "deploy_remoteFinished" | "deploy_bundleDirectoryExists" | "deploy_bundleFull" | "deploy_bundlePartial" | "deploy_bundleSelection" | "deploy_transportBodyLimitInvalid" | "deploy_transportKeyRingInvalid" | "deploy_uploadPasswordPrompt" | "deploy_uploadPasswordUnavailable" | "deploy_uploadPasswordCancelled" | "deploy_uploadPasswordInvalid" | "deploy_managedSecretsInvalid" | "deploy_secretImportFailed" | "deploy_projectNameRequired" | "deploy_projectNameOverrideRemoved" | "deploy_requestAccessInvalid" | "deploy_httpsPortsInvalid" | "deploy_httpsCertificateInvalid" | "deploy_bundleRuntime" | "deploy_bundleHttpOnly" | "deploy_bundleHttps" | "deploy_bundleAcme" | "deploy_bundleAccounts" | "deploy_bundleDirectories", options?: _h_ai_core.MessageOptions) => string;
1065
+ declare const deployM: (key: "deploy_notInitialized" | "deploy_initFailed" | "deploy_unsupportedProviderType" | "deploy_unsupportedProvisionerType" | "deploy_configTokenRequired" | "deploy_authRequired" | "deploy_authFailed" | "deploy_projectCreateFailed" | "deploy_uploadFailed" | "deploy_deployFailed" | "deploy_provisionFailed" | "deploy_adapterMissing" | "deploy_scanFailed" | "deploy_envVarFailed" | "deploy_credentialError" | "deploy_credentialInvalidKey" | "deploy_credentialSaved" | "deploy_credentialLoaded" | "deploy_configError" | "deploy_credentialMissing" | "deploy_apiError" | "deploy_fileUploadFailed" | "deploy_provisionNoResult" | "deploy_recoveryFailure" | "deploy_recoverySuggestion" | "deploy_commandTimeout" | "deploy_commandFailed" | "deploy_remoteConnectFailed" | "deploy_remoteRuntimeMissing" | "deploy_imageTransferFailed" | "deploy_healthCheckFailed" | "deploy_invalidEnvironment" | "deploy_environmentMissing" | "deploy_environmentReadFailed" | "deploy_environmentWriteFailed" | "deploy_multipleApplications" | "deploy_purposeSqlite" | "deploy_purposeDatabase" | "deploy_purposeMemory" | "deploy_purposeLocal" | "deploy_purposeCache" | "deploy_purposeStorage" | "deploy_purposeVector" | "deploy_purposeDisabled" | "deploy_purposeLdap" | "deploy_purposeConsole" | "deploy_purposeEmail" | "deploy_purposeSms" | "deploy_webProxyInvalid" | "deploy_webBaseConflict" | "deploy_storageProxyInvalid" | "deploy_storagePublicEndpointInvalid" | "deploy_storageBackendRequired" | "deploy_artifactInvalid" | "deploy_sshRequired" | "deploy_sshPasswordInvalid" | "deploy_sshAskpassFailed" | "deploy_sshAskpassCleanupFailed" | "deploy_targetAuth" | "deploy_targetPasswordEnv" | "deploy_bundleInstructions" | "deploy_bundleMetadata" | "deploy_targetHost" | "deploy_targetPort" | "deploy_targetUsername" | "deploy_targetIdentityFile" | "deploy_targetKnownHostsFile" | "deploy_targetStrictHostKeyChecking" | "deploy_targetConnectTimeoutSeconds" | "deploy_targetDirectory" | "deploy_targetBundle" | "deploy_bundleOnlyContainer" | "deploy_selectedContainerOnly" | "deploy_selectionInvalid" | "deploy_imageVersionRequired" | "deploy_bundleRuntimeRequired" | "deploy_bundleFailed" | "deploy_configFileInvalid" | "deploy_configFileUnreadable" | "deploy_bundleNameInvalid" | "deploy_localStopped" | "deploy_localUnknown" | "deploy_localNotStarted" | "deploy_commandOutputFailed" | "deploy_commandInputFailed" | "deploy_commandTreeActive" | "deploy_commandExecutionFailed" | "deploy_remoteUnknown" | "deploy_remoteFinished" | "deploy_bundleDirectoryExists" | "deploy_bundleFull" | "deploy_bundlePartial" | "deploy_bundleSelection" | "deploy_transportBodyLimitInvalid" | "deploy_transportKeyRingInvalid" | "deploy_uploadPasswordPrompt" | "deploy_uploadPasswordUnavailable" | "deploy_uploadPasswordCancelled" | "deploy_uploadPasswordInvalid" | "deploy_managedSecretsInvalid" | "deploy_secretImportFailed" | "deploy_projectNameRequired" | "deploy_projectNameOverrideRemoved" | "deploy_requestAccessInvalid" | "deploy_httpsPortsInvalid" | "deploy_httpsCertificateInvalid" | "deploy_bundleRuntime" | "deploy_bundleHttpOnly" | "deploy_bundleHttps" | "deploy_bundleAcme" | "deploy_bundleAccounts" | "deploy_bundleDirectories" | "deploy_downloadInvalid" | "deploy_imageSourceMissing" | "deploy_proxySystemUnsupported" | "deploy_middlewareFieldInvalid" | "deploy_s3Engine", options?: _h_ai_core.MessageOptions) => string;
1006
1066
 
1007
1067
  /**
1008
1068
  * 部署中间件的后端与连接字段目录,供扫描、CLI 和容器规划共同使用。
@@ -1027,6 +1087,8 @@ interface MiddlewareField {
1027
1087
  required?: boolean;
1028
1088
  /** 密码输入与私有环境文件写入标记。 */
1029
1089
  secret?: boolean;
1090
+ /** 自建服务会定稿此字段,默认模式允许尚未生成。 */
1091
+ managed?: boolean;
1030
1092
  /** 交互校验类型;端口范围为 1–65535。 */
1031
1093
  kind?: 'port' | 'boolean' | 'number' | 'url';
1032
1094
  /** 数值下限;未声明时为 0。 */
@@ -1051,6 +1113,26 @@ interface MiddlewareBackend {
1051
1113
  purpose: Parameters<typeof deployM>[0];
1052
1114
  /** 云自动开通器;缺失表示不能自动开通该云服务。 */
1053
1115
  provisioner?: 'neon' | 'upstash' | 'cloudflare-r2' | 'resend' | 'aliyun';
1116
+ /** 云凭据字段,由所属开通器 Schema 派生。 */
1117
+ cloudFields?: string[];
1118
+ /** 是否支持容器自动创建;省略为支持。 */
1119
+ containerSupported?: boolean;
1120
+ /** 自建容器的可选实现,配置位置属于 deploy.container。 */
1121
+ containerOptions?: Array<{
1122
+ /** deploy.container 中的字段。 */
1123
+ field: string;
1124
+ /** 对应细项环境变量。 */
1125
+ variable: string;
1126
+ /** 输入提示的消息键。 */
1127
+ purpose: Parameters<typeof deployM>[0];
1128
+ /** 未配置时的选择。 */
1129
+ defaultValue: string;
1130
+ /** 可选实现。 */
1131
+ choices: Array<{
1132
+ label: string; /** 配置值。 */
1133
+ value: string;
1134
+ }>;
1135
+ }>;
1054
1136
  /** 自定义连接需要逐项输入的字段。 */
1055
1137
  fields: MiddlewareField[];
1056
1138
  }
@@ -1078,7 +1160,87 @@ declare const DEPLOY_MIDDLEWARE: Record<ServiceType, MiddlewareBackend[]>;
1078
1160
  * }
1079
1161
  * ```
1080
1162
  */
1081
- declare function describeMiddlewareBackend(backend: MiddlewareBackend): string;
1163
+ declare function describeMiddlewareBackend(backend: Pick<MiddlewareBackend, 'purpose'>): string;
1164
+
1165
+ /** 中间件表单值与模块配置之间的部署适配;CLI 仅收集输入,不解释模块字段。 */
1166
+
1167
+ /**
1168
+ * 判断目标模式是否显式配置了所选连接,凭据可来自更高优先级的私有来源。
1169
+ * @param requirement - 扫描得到的连接需求。
1170
+ * @param backend - 选择的后端及连接字段目录。
1171
+ * @param environment - 合并值与目标文件的原始值。
1172
+ * @returns 目标文件声明后端和必要连接字段时为 true。
1173
+ * @example
1174
+ * ```ts
1175
+ * import { canKeepMiddleware, DEPLOY_MIDDLEWARE } from '@h-ai/deploy'
1176
+ * const keep = canKeepMiddleware({ service: 'cache', backend: 'memory', source: 'cache', configName: 'cache', configPath: [], envPrefix: 'HAI_CACHE', config: {} }, DEPLOY_MIDDLEWARE.cache[0]!, { environment: 'test', envDir: '.', values: {}, targetValues: { HAI_CACHE_TYPE: 'memory' } })
1177
+ * ```
1178
+ */
1179
+ declare function canKeepMiddleware(requirement: MiddlewareRequirement, backend: MiddlewareBackend, environment: DeploymentEnvironment): boolean;
1180
+ /**
1181
+ * 校验部署连接字段,TLS 复用数据库模块的公开 Schema。
1182
+ * @param options - 原始值、字段定义及实际后端。
1183
+ * @param options.value - 字面输入值。
1184
+ * @param options.field - 已声明的连接字段。
1185
+ * @param options.backend - 实际后端名称。
1186
+ * @returns 输入有效时为 true,不包含输入值或凭据。
1187
+ * @example
1188
+ * ```ts
1189
+ * import { validateMiddlewareField } from '@h-ai/deploy'
1190
+ * const valid = validateMiddlewareField({ value: '5432', field: { name: 'port', kind: 'port' }, backend: 'postgresql' })
1191
+ * ```
1192
+ */
1193
+ declare function validateMiddlewareField(options: {
1194
+ value: string;
1195
+ field: MiddlewareField;
1196
+ backend: string;
1197
+ }): boolean;
1198
+ /**
1199
+ * 将已校验表单值还原为连接字段类型,不进行 dotenv 序列化。
1200
+ * @param options - 输入值、字段和后端。
1201
+ * @param options.value - 字面输入值。
1202
+ * @param options.field - 已声明的连接字段。
1203
+ * @param options.backend - 实际后端名称。
1204
+ * @param options.managed - 默认开通时允许托管秘密尚未生成。
1205
+ * @returns 类型化值或配置错误;空值表示移除该可选字段。
1206
+ * @example
1207
+ * ```ts
1208
+ * import { parseMiddlewareField } from '@h-ai/deploy'
1209
+ * const parsed = parseMiddlewareField({ value: 'false', field: { name: 'secure', kind: 'boolean' }, backend: 'smtp' })
1210
+ * if (!parsed.success) throw new Error(parsed.error.message)
1211
+ * ```
1212
+ */
1213
+ declare function parseMiddlewareField(options: {
1214
+ value: string;
1215
+ field: MiddlewareField;
1216
+ backend: string;
1217
+ managed?: boolean;
1218
+ }): HaiResult<unknown>;
1219
+ /**
1220
+ * 保存选择后的完整连接,声明配置节点并清理该模式中被替换的旧连接字段。
1221
+ * @param environment - 目标环境快照,不修改进程环境。
1222
+ * @param options - 应用目录、扫描需求、后端、可选连接和其他生成项。
1223
+ * @param options.appDir - 应用配置文件所在根目录。
1224
+ * @param options.requirement - 扫描的中间件配置路径。
1225
+ * @param options.backend - 选定的后端。
1226
+ * @param options.configuration - 本次完整连接;云开通前可不提供。
1227
+ * @param options.updates - 同次选择需要保存的其他配置。
1228
+ * @returns 实际写入的变量名;错误不包含配置值。
1229
+ * @example
1230
+ * ```ts
1231
+ * import { loadDeploymentEnvironment, saveMiddlewareEnvironment } from '@h-ai/deploy'
1232
+ * const loaded = loadDeploymentEnvironment({ environment: 'test', envDir: process.cwd() })
1233
+ * if (!loaded.success) throw new Error(loaded.error.message)
1234
+ * const saved = saveMiddlewareEnvironment(loaded.data, { appDir: process.cwd(), requirement: { service: 'cache', backend: 'memory', source: 'cache', configName: 'cache', configPath: [], envPrefix: 'HAI_CACHE', config: {} }, backend: 'memory', configuration: { type: 'memory' } })
1235
+ * ```
1236
+ */
1237
+ declare function saveMiddlewareEnvironment(environment: DeploymentEnvironment, options: {
1238
+ appDir: string;
1239
+ requirement: MiddlewareRequirement;
1240
+ backend: string;
1241
+ configuration?: Record<string, unknown>;
1242
+ updates?: Record<string, unknown>;
1243
+ }): HaiResult<string[]>;
1082
1244
 
1083
1245
  /**
1084
1246
  * 查看与执行入口相同的扫描、环境、项目身份和制品校验结果。远端 current 只报告为待执行时核验。
@@ -1223,4 +1385,4 @@ declare function importDeploymentSecrets(options: {
1223
1385
  changed: boolean;
1224
1386
  }>>;
1225
1387
 
1226
- export { DEPLOY_MIDDLEWARE, type DeployAppOptions, type DeployCommandState, type DeployConfig, type DeployConfigInput, DeployConfigSchema, type DeployCredentialOperations, type DeployError, type DeployFunctions, type DeployRecoveryInfo, type DeployResult, type DeployScanOptions, type DeploymentArtifact, DeploymentArtifactSchema, type DeploymentEnvironment, type DockerSshProviderConfig, HaiDeployError, type MiddlewareBackend, type MiddlewareField, type MiddlewareMode, type MiddlewareRequirement, type PortExposeConfig, ProviderConfigSchema, type ProvisionResult, type ScanResult, type ServiceType, type SshConfig, artifactChecksum, createDeploymentPlan, deploy, describeMiddlewareBackend, getDeployCommandState, getDeployRecovery, importDeploymentSecrets, loadDeploymentConfig, loadDeploymentEnvironment, mergeEnvironmentLayers, normalizeProjectName, readDeploymentArtifact, saveDeploymentEnvironment };
1388
+ export { DEPLOY_MIDDLEWARE, type DeployAppOptions, type DeployCommandState, type DeployConfig, type DeployConfigInput, DeployConfigSchema, type DeployCredentialOperations, type DeployError, type DeployFunctions, type DeployRecoveryInfo, type DeployResult, type DeployScanOptions, type DeploymentArtifact, DeploymentArtifactSchema, type DeploymentEnvironment, type DockerSshProviderConfig, type DownloadProxyConfig, HaiDeployError, type ImageSourceConfig, type MiddlewareBackend, type MiddlewareField, type MiddlewareMode, type MiddlewareRequirement, type PortExposeConfig, ProviderConfigSchema, type ProvisionResult, type ScanResult, type ServiceType, type SshConfig, artifactChecksum, canKeepMiddleware, createDeploymentPlan, deploy, describeMiddlewareBackend, getDeployCommandState, getDeployRecovery, importDeploymentSecrets, loadDeploymentConfig, loadDeploymentEnvironment, mergeEnvironmentLayers, normalizeProjectName, parseMiddlewareField, readDeploymentArtifact, resolveDownloadProxy, resolveImageReference, saveDeploymentEnvironment, saveMiddlewareEnvironment, validateMiddlewareField };