@alipay/alipay-aipay 1.7.0 → 1.7.2

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.
Files changed (169) hide show
  1. package/README.md +30 -0
  2. package/dist/commands/install-current.js +15 -7
  3. package/dist/commands/install.js +20 -16
  4. package/dist/commands/uninstall.js +8 -3
  5. package/dist/commands/update.js +34 -16
  6. package/dist/index.js +10 -4
  7. package/dist/utils/channels.js +67 -0
  8. package/dist/utils/config.js +15 -11
  9. package/dist/utils/file.js +23 -10
  10. package/dist/utils/npm.js +19 -33
  11. package/package.json +8 -3
  12. package/skill/SKILL.md +2 -0
  13. package/skill/references/normal/json/release-channel.json +1 -0
  14. package/skill/references/normal/scripts/self_update.mjs +62 -17
  15. package/skill/references/normal/self-update.md +3 -1
  16. package/skill-pre/SKILL.md +65 -0
  17. package/skill-pre/VERSION +1 -0
  18. package/skill-pre/references/integration/flow.md +602 -0
  19. package/skill-pre/references/integration/modules/alipay-sdk-reminder.md +281 -0
  20. package/skill-pre/references/integration/modules/checklist.md +154 -0
  21. package/skill-pre/references/integration/modules/code-examples/csharp/1-/351/200/232/347/224/250/346/216/245/345/217/243//345/274/202/346/255/245/351/200/232/347/237/245/345/244/204/347/220/206/344/273/243/347/240/201/347/244/272/344/276/213.md +199 -0
  22. package/skill-pre/references/integration/modules/code-examples/csharp/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/345/205/263/351/227/255/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +68 -0
  23. package/skill-pre/references/integration/modules/code-examples/csharp/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +83 -0
  24. package/skill-pre/references/integration/modules/code-examples/csharp/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +80 -0
  25. package/skill-pre/references/integration/modules/code-examples/csharp/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +73 -0
  26. package/skill-pre/references/integration/modules/code-examples/csharp/2-/347/275/221/347/253/231/346/224/257/344/273/230//347/273/237/344/270/200/346/224/266/345/215/225/344/270/213/345/215/225/345/271/266/346/224/257/344/273/230/351/241/265/351/235/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +62 -0
  27. package/skill-pre/references/integration/modules/code-examples/csharp/3-APP/346/224/257/344/273/230/APP/346/224/257/344/273/230/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +132 -0
  28. package/skill-pre/references/integration/modules/code-examples/csharp/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.md +640 -0
  29. package/skill-pre/references/integration/modules/code-examples/java/1-/351/200/232/347/224/250/346/216/245/345/217/243//345/274/202/346/255/245/351/200/232/347/237/245/345/244/204/347/220/206/344/273/243/347/240/201/347/244/272/344/276/213.md +184 -0
  30. package/skill-pre/references/integration/modules/code-examples/java/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/345/205/263/351/227/255/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +72 -0
  31. package/skill-pre/references/integration/modules/code-examples/java/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +96 -0
  32. package/skill-pre/references/integration/modules/code-examples/java/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +81 -0
  33. package/skill-pre/references/integration/modules/code-examples/java/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +77 -0
  34. package/skill-pre/references/integration/modules/code-examples/java/2-/347/275/221/347/253/231/346/224/257/344/273/230//347/273/237/344/270/200/346/224/266/345/215/225/344/270/213/345/215/225/345/271/266/346/224/257/344/273/230/351/241/265/351/235/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +69 -0
  35. package/skill-pre/references/integration/modules/code-examples/java/3-APP/346/224/257/344/273/230/APP/346/224/257/344/273/230/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +138 -0
  36. package/skill-pre/references/integration/modules/code-examples/java/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemoController.md +623 -0
  37. package/skill-pre/references/integration/modules/code-examples/nodejs/1-/351/200/232/347/224/250/346/216/245/345/217/243//345/274/202/346/255/245/351/200/232/347/237/245/345/244/204/347/220/206/344/273/243/347/240/201/347/244/272/344/276/213.md +135 -0
  38. package/skill-pre/references/integration/modules/code-examples/nodejs/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/345/205/263/351/227/255/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +51 -0
  39. package/skill-pre/references/integration/modules/code-examples/nodejs/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +63 -0
  40. package/skill-pre/references/integration/modules/code-examples/nodejs/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +59 -0
  41. package/skill-pre/references/integration/modules/code-examples/nodejs/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +54 -0
  42. package/skill-pre/references/integration/modules/code-examples/nodejs/2-/347/275/221/347/253/231/346/224/257/344/273/230//347/273/237/344/270/200/346/224/266/345/215/225/344/270/213/345/215/225/345/271/266/346/224/257/344/273/230/351/241/265/351/235/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +84 -0
  43. package/skill-pre/references/integration/modules/code-examples/nodejs/3-APP/346/224/257/344/273/230/APP/346/224/257/344/273/230/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +71 -0
  44. package/skill-pre/references/integration/modules/code-examples/nodejs/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.md +498 -0
  45. package/skill-pre/references/integration/modules/code-examples/php/1-/351/200/232/347/224/250/346/216/245/345/217/243//345/274/202/346/255/245/351/200/232/347/237/245/345/244/204/347/220/206/344/273/243/347/240/201/347/244/272/344/276/213.md +157 -0
  46. package/skill-pre/references/integration/modules/code-examples/php/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/345/205/263/351/227/255/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +59 -0
  47. package/skill-pre/references/integration/modules/code-examples/php/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +73 -0
  48. package/skill-pre/references/integration/modules/code-examples/php/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +69 -0
  49. package/skill-pre/references/integration/modules/code-examples/php/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +65 -0
  50. package/skill-pre/references/integration/modules/code-examples/php/2-/347/275/221/347/253/231/346/224/257/344/273/230//347/273/237/344/270/200/346/224/266/345/215/225/344/270/213/345/215/225/345/271/266/346/224/257/344/273/230/351/241/265/351/235/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +59 -0
  51. package/skill-pre/references/integration/modules/code-examples/php/3-APP/346/224/257/344/273/230/APP/346/224/257/344/273/230/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +110 -0
  52. package/skill-pre/references/integration/modules/code-examples/php/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.md +806 -0
  53. package/skill-pre/references/integration/modules/code-examples/python/1-/351/200/232/347/224/250/346/216/245/345/217/243//345/274/202/346/255/245/351/200/232/347/237/245/345/244/204/347/220/206/344/273/243/347/240/201/347/244/272/344/276/213.md +128 -0
  54. package/skill-pre/references/integration/modules/code-examples/python/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/345/205/263/351/227/255/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +57 -0
  55. package/skill-pre/references/integration/modules/code-examples/python/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +70 -0
  56. package/skill-pre/references/integration/modules/code-examples/python/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +65 -0
  57. package/skill-pre/references/integration/modules/code-examples/python/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +62 -0
  58. package/skill-pre/references/integration/modules/code-examples/python/2-/347/275/221/347/253/231/346/224/257/344/273/230//347/273/237/344/270/200/346/224/266/345/215/225/344/270/213/345/215/225/345/271/266/346/224/257/344/273/230/351/241/265/351/235/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +51 -0
  59. package/skill-pre/references/integration/modules/code-examples/python/3-APP/346/224/257/344/273/230/APP/346/224/257/344/273/230/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +47 -0
  60. package/skill-pre/references/integration/modules/code-examples/python/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.md +541 -0
  61. package/skill-pre/references/integration/modules/interface-contract/aipay-interface-contract.md +52 -0
  62. package/skill-pre/references/integration/modules/interface-contract/apppay-interface-contract.md +45 -0
  63. package/skill-pre/references/integration/modules/interface-contract/common-trade-contract.md +42 -0
  64. package/skill-pre/references/integration/modules/interface-contract/notify-url-contract.md +68 -0
  65. package/skill-pre/references/integration/modules/interface-contract/webpay-interface-contract.md +44 -0
  66. package/skill-pre/references/integration/modules/interface-guide.md +61 -0
  67. package/skill-pre/references/integration/modules/product-decision.md +73 -0
  68. package/skill-pre/references/integration/modules/sandbox/a2m-sandbox-test.md +235 -0
  69. package/skill-pre/references/integration/modules/sandbox/alipay-sandbox-tool.md +142 -0
  70. package/skill-pre/references/integration/modules/sandbox/sandbox-setup-guide.md +239 -0
  71. package/skill-pre/references/integration/modules/scripts/local_402_sandbox_pay.py +900 -0
  72. package/skill-pre/references/integration/modules/scripts/sandbox_config.sh +347 -0
  73. package/skill-pre/references/integration/modules/troubleshooting-flow.md +28 -0
  74. package/skill-pre/references/normal/alipay-cli-env.md +169 -0
  75. package/skill-pre/references/normal/conversation-telemetry.md +101 -0
  76. package/skill-pre/references/normal/full-process-routing.md +92 -0
  77. package/skill-pre/references/normal/integration-worker.md +90 -0
  78. package/skill-pre/references/normal/json/customer-messages.json +1 -0
  79. package/skill-pre/references/normal/json/managed-jq-assets.json +1 -0
  80. package/skill-pre/references/normal/json/policy-rules.json +1 -0
  81. package/skill-pre/references/normal/json/release-channel.json +1 -0
  82. package/skill-pre/references/normal/rejection-guide.md +41 -0
  83. package/skill-pre/references/normal/scripts/agent_platform.mjs +43 -0
  84. package/skill-pre/references/normal/scripts/alipay_cli_env.mjs +34 -0
  85. package/skill-pre/references/normal/scripts/alipay_cli_env.sh +55 -0
  86. package/skill-pre/references/normal/scripts/alipay_cli_refresh.mjs +129 -0
  87. package/skill-pre/references/normal/scripts/auth_runtime_runner.mjs +60 -0
  88. package/skill-pre/references/normal/scripts/checklist_sections.mjs +43 -0
  89. package/skill-pre/references/normal/scripts/common.sh +365 -0
  90. package/skill-pre/references/normal/scripts/conversation_telemetry.mjs +105 -0
  91. package/skill-pre/references/normal/scripts/detect_dev_tool.sh +79 -0
  92. package/skill-pre/references/normal/scripts/flow_loader.mjs +237 -0
  93. package/skill-pre/references/normal/scripts/integration_context_runner.mjs +151 -0
  94. package/skill-pre/references/normal/scripts/integration_message_runner.mjs +1456 -0
  95. package/skill-pre/references/normal/scripts/interaction_reply.mjs +140 -0
  96. package/skill-pre/references/normal/scripts/managed_jq.mjs +215 -0
  97. package/skill-pre/references/normal/scripts/onboarding_discovery_runner.mjs +387 -0
  98. package/skill-pre/references/normal/scripts/onboarding_message_runner.mjs +1425 -0
  99. package/skill-pre/references/normal/scripts/onboarding_recovery_runner.mjs +100 -0
  100. package/skill-pre/references/normal/scripts/open_official_url.sh +205 -0
  101. package/skill-pre/references/normal/scripts/platform_compat.mjs +42 -0
  102. package/skill-pre/references/normal/scripts/preview_runtime.mjs +151 -0
  103. package/skill-pre/references/normal/scripts/project_route_inspector.sh +132 -0
  104. package/skill-pre/references/normal/scripts/python_script_runner.mjs +58 -0
  105. package/skill-pre/references/normal/scripts/render_customer_message.mjs +1792 -0
  106. package/skill-pre/references/normal/scripts/runtime.mjs +271 -0
  107. package/skill-pre/references/normal/scripts/self_update.mjs +376 -0
  108. package/skill-pre/references/normal/scripts/telemetry.mjs +2102 -0
  109. package/skill-pre/references/normal/self-update.md +7 -0
  110. package/skill-pre/references/normal/telemetry.md +70 -0
  111. package/skill-pre/references/onboarding/assets/keygen.html +927 -0
  112. package/skill-pre/references/onboarding/flow.md +607 -0
  113. package/skill-pre/references/onboarding/modules/app-release.md +90 -0
  114. package/skill-pre/references/onboarding/modules/authorization.md +43 -0
  115. package/skill-pre/references/onboarding/modules/error-handling.md +62 -0
  116. package/skill-pre/references/onboarding/modules/product-sign.md +49 -0
  117. package/skill-pre/references/onboarding/modules/scripts/app.sh +1485 -0
  118. package/skill-pre/references/onboarding/modules/scripts/ar_sign_apply.sh +331 -0
  119. package/skill-pre/references/onboarding/modules/scripts/auth.sh +1040 -0
  120. package/skill-pre/references/onboarding/modules/scripts/download_key_tool.sh +4 -0
  121. package/skill-pre/references/onboarding/modules/scripts/error_handler.sh +841 -0
  122. package/skill-pre/references/onboarding/modules/scripts/mcc.sh +1085 -0
  123. package/skill-pre/references/onboarding/modules/scripts/network_retry.sh +135 -0
  124. package/skill-pre/references/onboarding/modules/scripts/query_sign_status.sh +105 -0
  125. package/skill-pre/references/onboarding/modules/scripts/service.sh +528 -0
  126. package/skill-pre/references/onboarding/modules/scripts/sign_status_parser.sh +58 -0
  127. package/skill-pre/references/onboarding/modules/scripts/upload_screenshots.sh +208 -0
  128. package/skill-pre/references/onboarding/modules/scripts/upload_special_license.sh +195 -0
  129. package/skill-pre/references/onboarding/modules/service-registration.md +40 -0
  130. package/skill-pre/references/runtime-entry.md +99 -0
  131. package/dist/commands/install-current.d.ts +0 -4
  132. package/dist/commands/install-current.d.ts.map +0 -1
  133. package/dist/commands/install-current.js.map +0 -1
  134. package/dist/commands/install.d.ts +0 -10
  135. package/dist/commands/install.d.ts.map +0 -1
  136. package/dist/commands/install.js.map +0 -1
  137. package/dist/commands/prepare-tools.d.ts +0 -5
  138. package/dist/commands/prepare-tools.d.ts.map +0 -1
  139. package/dist/commands/prepare-tools.js.map +0 -1
  140. package/dist/commands/uninstall.d.ts +0 -10
  141. package/dist/commands/uninstall.d.ts.map +0 -1
  142. package/dist/commands/uninstall.js.map +0 -1
  143. package/dist/commands/update.d.ts +0 -10
  144. package/dist/commands/update.d.ts.map +0 -1
  145. package/dist/commands/update.js.map +0 -1
  146. package/dist/index.d.ts +0 -2
  147. package/dist/index.d.ts.map +0 -1
  148. package/dist/index.js.map +0 -1
  149. package/dist/types.d.ts +0 -42
  150. package/dist/types.d.ts.map +0 -1
  151. package/dist/types.js.map +0 -1
  152. package/dist/utils/alipay-cli.d.ts +0 -20
  153. package/dist/utils/alipay-cli.d.ts.map +0 -1
  154. package/dist/utils/alipay-cli.js.map +0 -1
  155. package/dist/utils/config.d.ts +0 -52
  156. package/dist/utils/config.d.ts.map +0 -1
  157. package/dist/utils/config.js.map +0 -1
  158. package/dist/utils/file.d.ts +0 -77
  159. package/dist/utils/file.d.ts.map +0 -1
  160. package/dist/utils/file.js.map +0 -1
  161. package/dist/utils/jq.d.ts +0 -17
  162. package/dist/utils/jq.d.ts.map +0 -1
  163. package/dist/utils/jq.js.map +0 -1
  164. package/dist/utils/npm.d.ts +0 -17
  165. package/dist/utils/npm.d.ts.map +0 -1
  166. package/dist/utils/npm.js.map +0 -1
  167. package/dist/utils/shell.d.ts +0 -24
  168. package/dist/utils/shell.d.ts.map +0 -1
  169. package/dist/utils/shell.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"channel":"pre"}
@@ -0,0 +1,41 @@
1
+ # 拒绝引导话术
2
+
3
+ > 本文件定义当用户咨询本 Skill 不支持的支付产品时的标准引导话术。
4
+ > 本文件位于 `references/normal/`,文中的 `scripts/...` 路径相对本目录。
5
+
6
+ ---
7
+
8
+ ## 标准拒绝引导
9
+
10
+ 当用户提及以下不支持的产品时,使用 `json/customer-messages.json` 的 `product.unsupported`,传入用户实际产品名。必须执行:
11
+
12
+ ```bash
13
+ node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" integration-message product-unsupported --product-name "$PRODUCT_NAME" --agent-platform "<AGENT_PLATFORM>" --session-id "<SESSION_ID>"
14
+ ```
15
+
16
+ 支持范围、开放平台文档、传统支付集成 Skill 和商家平台链接只在消息目录维护;本文件不复制标准正文。
17
+
18
+ ---
19
+
20
+ ## 适用场景
21
+
22
+ | 用户提及的产品 | 引导方式 |
23
+ |---------------|----------|
24
+ | 预授权支付 | 使用标准引导 |
25
+ | 商家扣款 | 使用标准引导 |
26
+ | 订单码支付 | 使用标准引导 |
27
+ | 当面付 | 使用标准引导 |
28
+ | 付款码 | 使用标准引导 |
29
+ | JSAPI支付 | 使用标准引导 |
30
+
31
+ > “网站支付”“手机网站支付”“H5支付”只是用户对网页场景的旧叫法,在本 Skill 中统一归为 **AI 网页应用收款**,不作为独立产品处理,也不使用拒绝话术。
32
+
33
+ ---
34
+
35
+ ## 调用位置
36
+
37
+ 本话术在以下位置被引用:
38
+ - `SKILL.md` → 支持范围
39
+ - `../integration/modules/product-decision.md` → 不支持的产品
40
+
41
+ **重要**:如需修改对客文字或链接,只修改 `json/customer-messages.json` 与对应 `json/policy-rules.json` 官方 URL;本文件只维护适用语义。
@@ -0,0 +1,43 @@
1
+ import path from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+
4
+ const MAX_PLATFORM_LENGTH = 40;
5
+ const ASCII_PLATFORM_RE = /^[a-z0-9.]{1,40}$/u;
6
+
7
+ export function normalizeAgentPlatform(value) {
8
+ const normalizedInput = String(value || '').normalize('NFKC');
9
+ if (/\p{C}/u.test(normalizedInput)) return 'unknown';
10
+ const raw = normalizedInput.trim();
11
+ if (!raw || [...raw].length > MAX_PLATFORM_LENGTH || /[\\/:@?#%]/u.test(raw)) return 'unknown';
12
+
13
+ const normalized = raw.toLowerCase().replace(/[_\s-]/gu, '');
14
+ if (normalized === 'claude') return 'claudecode';
15
+ if (ASCII_PLATFORM_RE.test(normalized)) return normalized;
16
+ return /[\p{L}\p{M}\p{N}]/u.test(raw) ? raw : 'unknown';
17
+ }
18
+
19
+ // Consume host context before dispatch so Node runners and Shell children share it.
20
+ export function applyAgentPlatform(args, env = process.env) {
21
+ const remaining = [];
22
+ let supplied = false;
23
+ for (let index = 0; index < args.length; index += 1) {
24
+ if (args[index] !== '--agent-platform') {
25
+ remaining.push(args[index]);
26
+ continue;
27
+ }
28
+ if (supplied) throw new Error('duplicate --agent-platform');
29
+ const value = args[++index];
30
+ if (value === undefined || value.startsWith('--')) throw new Error('missing --agent-platform value');
31
+ supplied = true;
32
+ env.ALIPAY_AIPAY_AGENT_PLATFORM = normalizeAgentPlatform(value);
33
+ }
34
+ return remaining;
35
+ }
36
+
37
+ if (process.argv[1] && fileURLToPath(import.meta.url) === path.resolve(process.argv[1])) {
38
+ if (process.argv[2] !== 'normalize' || process.argv.length !== 4) {
39
+ process.exitCode = 2;
40
+ } else {
41
+ process.stdout.write(normalizeAgentPlatform(process.argv[3]));
42
+ }
43
+ }
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+
3
+ import process from 'node:process';
4
+ import path from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+
7
+ import { checkCliEnvironment, isWindowsPlatform } from './platform_compat.mjs';
8
+
9
+ export function runAlipayCliEnvCli(argv = process.argv) {
10
+ const mode = argv[2];
11
+ if (!['check', 'integration-check'].includes(mode) || argv.length !== 3) {
12
+ console.error('用法: node alipay_cli_env.mjs <check|integration-check>');
13
+ process.exitCode = 1;
14
+ return;
15
+ }
16
+
17
+ const windows = isWindowsPlatform();
18
+ const missing = checkCliEnvironment({
19
+ requireJq: !windows,
20
+ requireAlipayCli: !windows
21
+ });
22
+
23
+ if (missing.length === 0) {
24
+ console.log('CLI_ENV:READY');
25
+ return;
26
+ }
27
+
28
+ console.log('CLI_ENV:NEEDS_SETUP');
29
+ console.log(`CLI_ENV_MISSING=${missing.join(',')}`);
30
+ }
31
+
32
+ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
33
+ runAlipayCliEnvCli();
34
+ }
@@ -0,0 +1,55 @@
1
+ #!/bin/bash
2
+
3
+ set -u
4
+
5
+ MODE="${1:-}"
6
+ if [ "$MODE" != "check" ] && [ "$MODE" != "integration-check" ]; then
7
+ echo "用法: bash alipay_cli_env.sh <check|integration-check> [--product-type aipay|webpay|apppay]" >&2
8
+ exit 1
9
+ fi
10
+ shift
11
+
12
+ case "${BASH_SOURCE[0]}" in
13
+ */*) SCRIPT_DIR="${BASH_SOURCE[0]%/*}" ;;
14
+ *) SCRIPT_DIR="." ;;
15
+ esac
16
+ # shellcheck source=/dev/null
17
+ source "${SCRIPT_DIR}/common.sh"
18
+
19
+ PRODUCT_TYPE=""
20
+ while [ "$#" -gt 0 ]; do
21
+ case "$1" in
22
+ --product-type)
23
+ [ "$#" -ge 2 ] || { echo "❌ 缺少参数值: $1" >&2; exit 1; }
24
+ PRODUCT_TYPE="$2"
25
+ shift 2
26
+ ;;
27
+ *)
28
+ echo "❌ 未知参数: $1" >&2
29
+ exit 1
30
+ ;;
31
+ esac
32
+ done
33
+
34
+ if [ -n "$PRODUCT_TYPE" ]; then
35
+ init_alipay_cli_product "$PRODUCT_TYPE" || exit 1
36
+ else
37
+ unset PRODUCT
38
+ fi
39
+
40
+ MISSING=()
41
+ command -v node >/dev/null 2>&1 || MISSING+=("node")
42
+ if ! command -v jq >/dev/null 2>&1 \
43
+ || ! jq --version >/dev/null 2>&1 \
44
+ || ! jq -n -e --arg value ok '$value == "ok"' >/dev/null 2>&1; then
45
+ MISSING+=("jq")
46
+ fi
47
+ if ! command -v alipay-cli >/dev/null 2>&1 || ! alipay-cli version >/dev/null 2>&1; then
48
+ MISSING+=("alipay-cli")
49
+ fi
50
+
51
+ if [ "${#MISSING[@]}" -eq 0 ]; then
52
+ echo "CLI_ENV:READY"
53
+ else
54
+ printf 'CLI_ENV:NEEDS_SETUP\nCLI_ENV_MISSING=%s\n' "$(IFS=,; echo "${MISSING[*]}")"
55
+ fi
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawnSync } from 'node:child_process';
4
+ import fs from 'node:fs';
5
+ import os from 'node:os';
6
+ import path from 'node:path';
7
+ import process from 'node:process';
8
+ import { fileURLToPath } from 'node:url';
9
+
10
+ const installUrl = 'https://opengw.alipay.com/alipaycli/install';
11
+ const internalPrefix = 'ALIPAY_AIPAY_INTERNAL:';
12
+ const refreshTimeoutMs = 60 * 1000;
13
+ const verifyTimeoutMs = 5 * 1000;
14
+
15
+ function refreshTimeoutBudget() {
16
+ if (process.env.ALIPAY_AIPAY_TEST_MODE !== '1') return refreshTimeoutMs;
17
+ const value = Number(process.env.ALIPAY_AIPAY_CLI_REFRESH_TEST_TIMEOUT_MS);
18
+ return Number.isInteger(value) && value >= 50 && value <= refreshTimeoutMs ? value : refreshTimeoutMs;
19
+ }
20
+
21
+ function cleanChildEnv(extra = {}) {
22
+ const env = { ...process.env, ...extra };
23
+ delete env.PLATFORM;
24
+ delete env.PLATFORM_ID;
25
+ delete env.PRODUCT;
26
+ delete env.ALIPAYCLI_BIZ_INFO;
27
+ return env;
28
+ }
29
+
30
+ function homeDir() {
31
+ const home = process.env.HOME || os.homedir();
32
+ if (typeof home !== 'string' || !path.isAbsolute(home) || home === path.parse(home).root) {
33
+ return '';
34
+ }
35
+ return home;
36
+ }
37
+
38
+ function isPermissionFailure(text = '') {
39
+ return /permission denied|operation not permitted|EACCES|EPERM|access denied/iu.test(text);
40
+ }
41
+
42
+ function isNetworkFailure(status, text = '') {
43
+ const networkCurlStatuses = new Set([5, 6, 7, 18, 28, 35, 52, 55, 56, 92]);
44
+ return networkCurlStatuses.has(Number(status)) ||
45
+ /could not resolve|failed to connect|connection (?:refused|reset)|timed? out|timeout|network|socket|tls|ssl|fetch failed|ENOTFOUND|ETIMEDOUT|ECONNRESET|ECONNREFUSED|EAI_AGAIN/iu.test(text);
46
+ }
47
+
48
+ function emit(kind) {
49
+ process.stderr.write(`${internalPrefix}ALIPAY_CLI_REFRESH=${kind}\n`);
50
+ }
51
+
52
+ function commandOutput(result) {
53
+ return `${result.stdout || ''}\n${result.stderr || ''}\n${result.error?.message || ''}`;
54
+ }
55
+
56
+ function verifyAlipayCli(binDir) {
57
+ const command = path.join(binDir, process.platform === 'win32' ? 'alipay-cli.cmd' : 'alipay-cli');
58
+ const result = spawnSync(command, ['version'], {
59
+ encoding: 'utf8',
60
+ env: cleanChildEnv({ PATH: `${binDir}${path.delimiter}${process.env.PATH || ''}` }),
61
+ shell: false,
62
+ stdio: 'ignore',
63
+ timeout: verifyTimeoutMs
64
+ });
65
+ return result.status === 0;
66
+ }
67
+
68
+ export function runAlipayCliRefreshCli(argv = process.argv) {
69
+ if (argv.length !== 3 || argv[2] !== 'refresh-alipay-cli') {
70
+ console.error('用法: node alipay_cli_refresh.mjs refresh-alipay-cli');
71
+ process.exitCode = 1;
72
+ return;
73
+ }
74
+
75
+ const home = homeDir();
76
+ if (!home) {
77
+ emit('FAILED');
78
+ return;
79
+ }
80
+
81
+ const binDir = path.join(home, '.local', 'bin');
82
+ try {
83
+ fs.mkdirSync(binDir, { recursive: true, mode: 0o755 });
84
+ } catch (error) {
85
+ emit(isPermissionFailure(error?.message || '') ? 'RETRY_WITH_LOCAL_FS_PERMISSION' : 'FAILED');
86
+ return;
87
+ }
88
+
89
+ const timeout = refreshTimeoutBudget();
90
+ const curl = spawnSync('curl', ['-fsSL', '--connect-timeout', '10', '--max-time', '60', installUrl], {
91
+ encoding: 'utf8',
92
+ env: cleanChildEnv(),
93
+ maxBuffer: 30 * 1024 * 1024,
94
+ shell: false,
95
+ timeout
96
+ });
97
+ if (curl.error || curl.status !== 0) {
98
+ const output = commandOutput(curl);
99
+ emit(isNetworkFailure(curl.status, output) ? 'RETRY_WITH_NETWORK' : 'FAILED');
100
+ return;
101
+ }
102
+
103
+ const installEnv = cleanChildEnv({
104
+ ALIPAY_CLI_BIN: binDir,
105
+ ALIPAY_CLI_SKIP_VERIFY: 'true',
106
+ PATH: `${binDir}${path.delimiter}${process.env.PATH || ''}`
107
+ });
108
+ const bash = spawnSync('bash', [], {
109
+ input: curl.stdout,
110
+ encoding: 'utf8',
111
+ env: installEnv,
112
+ maxBuffer: 30 * 1024 * 1024,
113
+ shell: false,
114
+ timeout
115
+ });
116
+ if (bash.error || bash.status !== 0) {
117
+ const output = commandOutput(bash);
118
+ if (isNetworkFailure(bash.status, output)) emit('RETRY_WITH_NETWORK');
119
+ else if (isPermissionFailure(output)) emit('RETRY_WITH_LOCAL_FS_PERMISSION');
120
+ else emit('FAILED');
121
+ return;
122
+ }
123
+
124
+ emit(verifyAlipayCli(binDir) ? 'READY' : 'VERIFY_FAILED');
125
+ }
126
+
127
+ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
128
+ runAlipayCliRefreshCli();
129
+ }
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawnSync } from 'node:child_process';
4
+ import process from 'node:process';
5
+
6
+ const internalPrefix = 'ALIPAY_AIPAY_INTERNAL:';
7
+ const autoMismatchFlows = new Set(['SCOPE_MISMATCH', 'MCC_MISMATCH']);
8
+
9
+ function runAuthScript(script, cwd, args, stdio) {
10
+ const result = spawnSync('bash', [script, ...args], {
11
+ cwd,
12
+ env: process.env,
13
+ encoding: stdio === 'pipe' ? 'utf8' : undefined,
14
+ stdio,
15
+ shell: false
16
+ });
17
+ if (result.error) throw result.error;
18
+ return result;
19
+ }
20
+
21
+ function authFlowValues(stderr) {
22
+ const prefix = `${internalPrefix}AUTH_FLOW:`;
23
+ return String(stderr || '')
24
+ .split(/\r?\n/u)
25
+ .filter((line) => line.startsWith(prefix))
26
+ .map((line) => line.slice(prefix.length));
27
+ }
28
+
29
+ function withoutIntermediateFlow(stderr, flow) {
30
+ const marker = `${internalPrefix}AUTH_FLOW:${flow}`;
31
+ const source = String(stderr || '');
32
+ return source.split(/\r?\n/u).filter((line) => line !== marker).join('\n');
33
+ }
34
+
35
+ export function runAuthRuntime(script, cwd, args) {
36
+ if (args[0] !== 'init') {
37
+ const result = runAuthScript(script, cwd, args, 'inherit');
38
+ return Number.isInteger(result.status) ? result.status : 1;
39
+ }
40
+
41
+ const initial = runAuthScript(script, cwd, args, 'pipe');
42
+ const initialStatus = Number.isInteger(initial.status) ? initial.status : 1;
43
+ const flows = authFlowValues(initial.stderr);
44
+ const flow = flows.length === 1 ? flows[0] : '';
45
+ const canAutoRecover = initialStatus === 1
46
+ && initial.signal === null
47
+ && autoMismatchFlows.has(flow)
48
+ && String(initial.stdout || '').trim() === '';
49
+
50
+ if (!canAutoRecover) {
51
+ process.stdout.write(initial.stdout || '');
52
+ process.stderr.write(initial.stderr || '');
53
+ return initialStatus;
54
+ }
55
+
56
+ process.stderr.write(withoutIntermediateFlow(initial.stderr, flow));
57
+ process.stderr.write(`${internalPrefix}AUTH_AUTO_MISMATCH=${flow}\n`);
58
+ const recovered = runAuthScript(script, cwd, ['mismatch', ...args.slice(1)], 'inherit');
59
+ return Number.isInteger(recovered.status) ? recovered.status : 1;
60
+ }
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+
7
+ const scriptDir = path.dirname(fileURLToPath(import.meta.url));
8
+ export const checklistPath = path.resolve(scriptDir, '../../integration/modules/checklist.md');
9
+ const productTypes = new Set(['aipay', 'webpay', 'apppay']);
10
+ const declarationPattern = /<!-- ALIPAY_AIPAY_CHECKLIST_PRODUCTS:([a-z,]+) -->\s*\n(## [^#\n].+)([\s\S]*?)(?=<!-- ALIPAY_AIPAY_CHECKLIST_PRODUCTS:|\s*$)/gu;
11
+
12
+ function checklistDeclarations(source) {
13
+ const declarations = [];
14
+ const declaredHeadings = new Set();
15
+ for (const match of source.matchAll(declarationPattern)) {
16
+ const products = match[1].split(',');
17
+ const heading = match[2].slice(3).trim();
18
+ if (products.some((product) => !productTypes.has(product)) || declaredHeadings.has(heading)) {
19
+ throw new Error('checklist 产品声明非法或重复');
20
+ }
21
+ declaredHeadings.add(heading);
22
+ declarations.push({
23
+ products: new Set(products),
24
+ heading,
25
+ markdown: `${match[2]}${match[3]}`.trim()
26
+ });
27
+ }
28
+ const allHeadings = [...source.matchAll(/^## ([^#].+)$/gmu)].map((match) => match[1]);
29
+ if (allHeadings.length !== declarations.length || allHeadings.some((heading) => !declaredHeadings.has(heading))) {
30
+ throw new Error('checklist 存在未声明产品范围的章节');
31
+ }
32
+ return declarations;
33
+ }
34
+
35
+ export function checklistForProduct(productType, source = fs.readFileSync(checklistPath, 'utf8')) {
36
+ if (!productTypes.has(productType)) throw new Error('checklist product-type 非法');
37
+ const applicable = checklistDeclarations(source).filter(({ products }) => products.has(productType));
38
+ if (applicable.length === 0) throw new Error(`checklist 缺少 ${productType} 适用章节`);
39
+ return {
40
+ sections: applicable.map(({ heading }) => heading),
41
+ markdown: applicable.map(({ markdown }) => markdown).join('\n\n')
42
+ };
43
+ }