@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,135 @@
1
+ #!/bin/bash
2
+
3
+ # Source after error_handler.sh. This wrapper never changes MCP argv or business JSON.
4
+
5
+ NETWORK_RETRY_CLASS=""
6
+ NETWORK_DISPATCH_STATE=""
7
+ NETWORK_ATTEMPTS=0
8
+
9
+ network_retry_is_local_transport_error() {
10
+ printf '%s' "$1" | grep -Eqi \
11
+ 'network[ _]error|网络连接失败|could not resolve host|name or service not known|nodename nor servname|connection refused|failed to connect|fetch failed|socket hang up|econn(refused|reset)|enotfound|eai_again|etimedout|(^|[^[:alpha:]])timeout([^[:alpha:]]|$)|timed out|tls[^[:cntrl:]]*(error|failed|failure)|network access[^[:cntrl:]]*(denied|blocked)[^[:cntrl:]]*before connection'
12
+ }
13
+
14
+ network_retry_is_not_sent() {
15
+ printf '%s' "$1" | grep -Eqi \
16
+ 'could not resolve host|name or service not known|nodename nor servname|connection refused|network access[^[:cntrl:]]*(denied|blocked)[^[:cntrl:]]*before connection'
17
+ }
18
+
19
+ network_retry_is_explicit_network_restriction() {
20
+ printf '%s' "$1" | grep -Eqi \
21
+ 'network access[^[:cntrl:]]*(denied|blocked)[^[:cntrl:]]*before connection'
22
+ }
23
+
24
+ network_retry_emit_exhausted() {
25
+ local action_name="$1" classification="$2" dispatch="$3" attempt="$4" evidence="$5"
26
+ local recovery="NONE"
27
+ if network_retry_is_local_transport_error "$evidence"; then
28
+ recovery="RETRY_WITH_NETWORK"
29
+ fi
30
+ echo "ALIPAY_AIPAY_INTERNAL:NETWORK_RETRY_EXHAUSTED=${action_name}:${classification}:${dispatch}:${attempt}:${recovery}" >&2
31
+ }
32
+
33
+ run_network_retry() {
34
+ local result_var="$1" operation="$2" action_name="$3"
35
+ shift 3
36
+ [ "${1:-}" = "--" ] || { echo "NETWORK_RETRY_ERROR:缺少 -- 参数分隔符" >&2; return 64; }
37
+ shift
38
+ [ "$#" -gt 0 ] || { echo "NETWORK_RETRY_ERROR:缺少命令 argv" >&2; return 64; }
39
+ case "$operation" in read|write) ;; *) echo "NETWORK_RETRY_ERROR:operation 必须为 read 或 write" >&2; return 64 ;; esac
40
+
41
+ local max_retries="${NETWORK_RETRY_MAX_RETRIES:-2}"
42
+ local delay_seconds="${NETWORK_RETRY_DELAY_SECONDS:-3}"
43
+ local attempt=0 stdout_file stderr_file stdout stderr combined result_payload rc classification transient dispatch
44
+ stdout_file=$(mktemp "${TMPDIR:-/tmp}/alipay-aipay-stdout.XXXXXX") || return 1
45
+ stderr_file=$(mktemp "${TMPDIR:-/tmp}/alipay-aipay-stderr.XXXXXX") || { rm -f "$stdout_file"; return 1; }
46
+ chmod 600 "$stdout_file" "$stderr_file" 2>/dev/null || true
47
+ trap 'rm -f "$stdout_file" "$stderr_file"; trap - RETURN' RETURN
48
+
49
+ while true; do
50
+ attempt=$((attempt + 1))
51
+ : > "$stdout_file"
52
+ : > "$stderr_file"
53
+ "$@" >"$stdout_file" 2>"$stderr_file"
54
+ rc=$?
55
+ stdout=$(cat "$stdout_file")
56
+ stderr=$(cat "$stderr_file")
57
+ combined=$(printf '%s\n%s' "$stdout" "$stderr")
58
+ classification=""
59
+ transient=false
60
+ dispatch="MAYBE_SENT"
61
+
62
+ if type alipay_cli_has_local_state_permission_error >/dev/null 2>&1 &&
63
+ alipay_cli_has_local_state_permission_error "$combined"; then
64
+ NETWORK_RETRY_CLASS="CLI_LOCAL_FS_PERMISSION"
65
+ NETWORK_DISPATCH_STATE="MAYBE_SENT"
66
+ NETWORK_ATTEMPTS="$attempt"
67
+ printf -v "$result_var" '%s' "$stdout"
68
+ if [ "$operation" = "read" ]; then
69
+ if [ "${ALIPAY_AIPAY_SUPPRESS_LOCAL_FS_RETRY_MARKER:-0}" != "1" ]; then
70
+ emit_control "CLI_FLOW:RETRY_WITH_LOCAL_FS_PERMISSION"
71
+ fi
72
+ return "${ALIPAY_CLI_LOCAL_STATE_PERMISSION_EXIT_CODE:-77}"
73
+ fi
74
+ return 75
75
+ fi
76
+
77
+ local stdout_is_business_json=false unwrapped_stdout=""
78
+ if [ -n "$stdout" ]; then
79
+ classification=$(detect_error "$stdout" 2>/dev/null || true)
80
+ unwrapped_stdout=$(unwrap_mcp "$stdout" 2>/dev/null || true)
81
+ if printf '%s' "$unwrapped_stdout" | jq -e . >/dev/null 2>&1; then
82
+ stdout_is_business_json=true
83
+ fi
84
+ # 合法业务 JSON 始终以 stdout 为准。普通启动日志会被 detect_error 归为
85
+ # CLI_ERROR;此时仍须检查 stderr,避免真实连接失败被非空 stdout 掩盖。
86
+ if [ "$stdout_is_business_json" != true ] && [ "$rc" -ne 0 ] && [ -n "$stderr" ]; then
87
+ classification=$(detect_error "$stderr" 2>/dev/null || true)
88
+ fi
89
+ elif [ -n "$stderr" ]; then
90
+ classification=$(detect_error "$stderr" 2>/dev/null || true)
91
+ fi
92
+
93
+ case "$classification" in
94
+ MCP_SERVICE_ERROR|SERVICE_UNSTABLE) transient=true ;;
95
+ *)
96
+ if [ "$stdout_is_business_json" != true ] && { [ "$rc" -ne 0 ] || [ -n "$stderr" ]; } && network_retry_is_local_transport_error "$stderr"; then
97
+ classification="LOCAL_TRANSPORT_ERROR"
98
+ transient=true
99
+ fi
100
+ ;;
101
+ esac
102
+
103
+ if network_retry_is_not_sent "$stderr"; then
104
+ dispatch="NOT_SENT"
105
+ fi
106
+
107
+ NETWORK_RETRY_CLASS="$classification"
108
+ NETWORK_DISPATCH_STATE="$dispatch"
109
+ NETWORK_ATTEMPTS="$attempt"
110
+ result_payload="$stdout"
111
+ if [ "$stdout_is_business_json" != true ] && [ "$rc" -ne 0 ] && [ -n "$stderr" ]; then
112
+ result_payload="$stderr"
113
+ fi
114
+ printf -v "$result_var" '%s' "$result_payload"
115
+
116
+ if [ "$transient" != true ]; then
117
+ return 0
118
+ fi
119
+
120
+ if [ "$operation" = "write" ] && [ "$dispatch" != "NOT_SENT" ]; then
121
+ return 75
122
+ fi
123
+
124
+ if network_retry_is_explicit_network_restriction "$combined"; then
125
+ network_retry_emit_exhausted "$action_name" "$classification" "$dispatch" "$attempt" "$combined"
126
+ return 76
127
+ fi
128
+
129
+ if [ "$attempt" -gt "$max_retries" ]; then
130
+ network_retry_emit_exhausted "$action_name" "$classification" "$dispatch" "$attempt" "$combined"
131
+ return 76
132
+ fi
133
+ sleep "$delay_seconds"
134
+ done
135
+ }
@@ -0,0 +1,105 @@
1
+ #!/bin/bash
2
+ #=============================================================================
3
+ # 脚本名称: query_sign_status.sh
4
+ # 功能描述: 查询签约状态并根据结果判断后续流程
5
+ # 调用位置: Step 3.1 状态与资源查询
6
+ # 调用前置: 脚本通过 error_handler.sh 间接初始化 DEV_TOOL_NAME/PLATFORM_ID;需传入 --sales-code,或兼容使用 SALES_CODE 环境变量
7
+ # 用法: bash query_sign_status.sh --sales-code <code> [--product-type aipay|webpay|apppay]
8
+ # 返回值: 在 stderr 输出签约状态控制信号;stdout 只保留受控错误正文
9
+ # SIGN_STATUS=NOT_SIGNED | SIGN_STATUS=SIGNED_EFFECTIVE | SIGN_STATUS=SIGN_SUBMITTED | SIGN_STATUS=OTHER_STATUS
10
+ # AI 按量付费: FLOW:AI_PAY_NOT_SIGNED | FLOW:AI_PAY_SIGNED
11
+ # AI 网页应用收款: FLOW:PC_WEB_NOT_SIGNED | FLOW:PC_WEB_SIGNED
12
+ # AI 移动应用收款: FLOW:APP_NOT_SIGNED | FLOW:APP_SIGNED
13
+ #=============================================================================
14
+
15
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16
+
17
+ # 一次性 source error_handler(含 unwrap_mcp)
18
+ if [ -f "${SCRIPT_DIR}/error_handler.sh" ]; then
19
+ source "${SCRIPT_DIR}/error_handler.sh"
20
+ else
21
+ echo "❌ 缺少错误处理脚本: ${SCRIPT_DIR}/error_handler.sh"
22
+ exit 1
23
+ fi
24
+ source "${SCRIPT_DIR}/network_retry.sh"
25
+ source "${SCRIPT_DIR}/sign_status_parser.sh"
26
+
27
+ require_command jq || exit 1
28
+ require_command alipay-cli || exit 1
29
+
30
+ export PRODUCT_TYPE="${PRODUCT_TYPE:-unknown}"
31
+
32
+ while [[ $# -gt 0 ]]; do
33
+ case $1 in
34
+ --sales-code)
35
+ [ $# -ge 2 ] || { echo "❌ 缺少参数值: $1"; exit 1; }
36
+ SALES_CODE="$2"; shift 2 ;;
37
+ --product-type)
38
+ [ $# -ge 2 ] || { echo "❌ 缺少参数值: $1"; exit 1; }
39
+ PRODUCT_TYPE="$2"; shift 2 ;;
40
+ *)
41
+ echo "❌ 未知参数: $1"
42
+ echo "用法: bash query_sign_status.sh --sales-code <code> [--product-type aipay|webpay|apppay]"
43
+ exit 1 ;;
44
+ esac
45
+ done
46
+
47
+ if [ -z "$SALES_CODE" ]; then
48
+ echo "❌ 缺少 salesCode(请传入 --sales-code,或设置 SALES_CODE 环境变量)"
49
+ exit 1
50
+ fi
51
+
52
+ case "$SALES_CODE" in
53
+ "I1080300001000160457")
54
+ EXPECTED_PRODUCT_TYPE="aipay"
55
+ ;;
56
+ "I1080300001000041203")
57
+ EXPECTED_PRODUCT_TYPE="webpay"
58
+ ;;
59
+ "I1080300001000041313")
60
+ EXPECTED_PRODUCT_TYPE="apppay"
61
+ ;;
62
+ *)
63
+ echo "❌ 未知 SALES_CODE: ${SALES_CODE}"
64
+ exit 1
65
+ ;;
66
+ esac
67
+
68
+ if [ "$PRODUCT_TYPE" != "unknown" ] && [ "$PRODUCT_TYPE" != "$EXPECTED_PRODUCT_TYPE" ]; then
69
+ echo "❌ PRODUCT_TYPE 与 SALES_CODE 不匹配:PRODUCT_TYPE=${PRODUCT_TYPE}, SALES_CODE=${SALES_CODE}"
70
+ echo "📋 期望 PRODUCT_TYPE=${EXPECTED_PRODUCT_TYPE}"
71
+ exit 1
72
+ fi
73
+
74
+ init_alipay_cli_product "$EXPECTED_PRODUCT_TYPE" || exit 1
75
+
76
+ # 查询签约状态
77
+ require_alipay_cli_local_state_access_or_emit || exit "$?"
78
+ export PLATFORM="${DEV_TOOL_NAME}" PLATFORM_ID="${PLATFORM_ID:-}"
79
+ run_network_retry RESULT read query_sign_status -- alipay-cli mcp call ar-query.queryArInfosBySalesProd \
80
+ -d "{\"request\":{\"salesProductCodes\":[\"${SALES_CODE}\"]},\"ctx\":{}}" \
81
+ --json
82
+ RETRY_RC=$?
83
+ if [ "$RETRY_RC" -eq "${ALIPAY_CLI_LOCAL_STATE_PERMISSION_EXIT_CODE:-77}" ]; then
84
+ exit "$RETRY_RC"
85
+ fi
86
+ if [ "$RETRY_RC" -ne 0 ]; then
87
+ echo "❌ 签约状态查询因网络或服务异常在自动重试两次后仍未恢复"
88
+ exit 1
89
+ fi
90
+
91
+ # 错误检测
92
+ if ! handle_error "$RESULT" "MCP_AUTHENTICATED_CALL"; then
93
+ exit 1
94
+ fi
95
+
96
+ # 解包 MCP 信封后解析业务字段
97
+ BUSINESS=$(unwrap_mcp "$RESULT")
98
+
99
+ # 只有明确返回数组才可判断签约状态;缺少字段必须阻断,避免误判为未签约。
100
+ if ! SIGN_STATUS_OUTPUT=$(emit_sign_status_from_business "$BUSINESS" "$SALES_CODE"); then
101
+ echo "❌ 签约状态返回结构异常,无法解析 arInfoList"
102
+ exit 1
103
+ fi
104
+ printf '%s\n' "$SIGN_STATUS_OUTPUT" \
105
+ | while IFS= read -r marker; do emit_control "$marker"; done