@alipay/alipay-aipay 1.2.2 → 1.5.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/README.md +5 -0
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +13 -12
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/uninstall.d.ts.map +1 -1
- package/dist/commands/uninstall.js +17 -9
- package/dist/commands/uninstall.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +5 -5
- package/dist/commands/update.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/utils/config.d.ts +5 -3
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +34 -12
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/file.d.ts +8 -0
- package/dist/utils/file.d.ts.map +1 -1
- package/dist/utils/file.js +161 -9
- package/dist/utils/file.js.map +1 -1
- package/dist/utils/jq.d.ts.map +1 -1
- package/dist/utils/jq.js +8 -0
- package/dist/utils/jq.js.map +1 -1
- package/package.json +9 -5
- package/skill/SKILL.md +15 -169
- package/skill/VERSION +1 -1
- package/skill/references/integration/flow.md +388 -291
- package/skill/references/integration/modules/alipay-sdk-reminder.md +5 -3
- package/skill/references/integration/modules/checklist.md +54 -32
- package/skill/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
- package/skill/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 +8 -4
- package/skill/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 +6 -2
- package/skill/references/integration/modules/code-examples/csharp/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.cs +3 -1
- package/skill/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
- package/skill/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 +4 -1
- package/skill/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 +5 -2
- package/skill/references/integration/modules/code-examples/java/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemoController.java +3 -1
- package/skill/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
- package/skill/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 +16 -10
- package/skill/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 +10 -4
- package/skill/references/integration/modules/code-examples/nodejs/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.js +2 -1
- package/skill/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
- package/skill/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 +4 -1
- package/skill/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 +5 -2
- package/skill/references/integration/modules/code-examples/php/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.php +2 -1
- package/skill/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
- package/skill/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 +4 -1
- package/skill/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 +5 -1
- package/skill/references/integration/modules/code-examples/python/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.py +4 -2
- package/skill/references/integration/modules/interface-contract/aipay-interface-contract.md +52 -0
- package/skill/references/integration/modules/interface-contract/apppay-interface-contract.md +45 -0
- package/skill/references/integration/modules/interface-contract/common-trade-contract.md +42 -0
- package/skill/references/integration/modules/interface-contract/notify-url-contract.md +68 -0
- package/skill/references/integration/modules/interface-contract/webpay-interface-contract.md +44 -0
- package/skill/references/integration/modules/interface-guide.md +38 -71
- package/skill/references/integration/modules/product-decision.md +18 -35
- package/skill/references/integration/modules/sandbox/a2m-sandbox-test.md +62 -94
- package/skill/references/integration/modules/sandbox/alipay-sandbox-tool.md +43 -40
- package/skill/references/integration/modules/sandbox/sandbox-setup-guide.md +93 -114
- package/skill/references/integration/modules/scripts/local_402_sandbox_pay.py +358 -148
- package/skill/references/integration/modules/scripts/sandbox_config.sh +299 -0
- package/skill/references/integration/modules/troubleshooting-flow.md +28 -0
- package/skill/references/normal/alipay-cli-env.md +15 -5
- package/skill/references/normal/full-process-routing.md +82 -0
- package/skill/references/normal/json/customer-messages.json +942 -0
- package/skill/references/normal/json/policy-rules.json +179 -0
- package/skill/references/normal/rejection-guide.md +12 -7
- package/skill/references/normal/scripts/alipay_cli_env.mjs +33 -0
- package/skill/references/normal/scripts/alipay_cli_env.sh +55 -0
- package/skill/references/normal/scripts/common.sh +151 -0
- package/skill/references/normal/scripts/detect_dev_tool.sh +5 -1
- package/skill/references/normal/scripts/flow_loader.mjs +241 -0
- package/skill/references/normal/scripts/integration_context_runner.mjs +166 -0
- package/skill/references/normal/scripts/integration_message_runner.mjs +1023 -0
- package/skill/references/normal/scripts/interaction_reply.mjs +133 -0
- package/skill/references/normal/scripts/onboarding_discovery_runner.mjs +224 -0
- package/skill/references/normal/scripts/onboarding_message_runner.mjs +451 -0
- package/skill/references/normal/scripts/onboarding_recovery_runner.mjs +96 -0
- package/skill/references/normal/scripts/open_official_url.sh +82 -0
- package/skill/references/normal/scripts/platform_compat.mjs +39 -0
- package/skill/references/normal/scripts/project_route_inspector.sh +132 -0
- package/skill/references/normal/scripts/python_script_runner.mjs +56 -0
- package/skill/references/normal/scripts/render_customer_message.mjs +1288 -0
- package/skill/references/normal/scripts/self_update.mjs +160 -0
- package/skill/references/normal/scripts/telemetry.mjs +1327 -0
- package/skill/references/normal/self-update.md +18 -51
- package/skill/references/normal/telemetry.md +26 -0
- package/skill/references/onboarding/flow.md +421 -309
- package/skill/references/onboarding/modules/app-release.md +44 -438
- package/skill/references/onboarding/modules/authorization.md +25 -281
- package/skill/references/onboarding/modules/error-handling.md +31 -237
- package/skill/references/onboarding/modules/product-sign.md +25 -294
- package/skill/references/onboarding/modules/scripts/app.sh +445 -169
- package/skill/references/onboarding/modules/scripts/ar_sign_apply.sh +47 -28
- package/skill/references/onboarding/modules/scripts/auth.sh +484 -167
- package/skill/references/onboarding/modules/scripts/download_key_tool.sh +157 -0
- package/skill/references/onboarding/modules/scripts/error_handler.sh +101 -130
- package/skill/references/onboarding/modules/scripts/network_retry.sh +96 -0
- package/skill/references/onboarding/modules/scripts/query_sign_status.sh +20 -71
- package/skill/references/onboarding/modules/scripts/service.sh +154 -89
- package/skill/references/onboarding/modules/scripts/sign_status_parser.sh +58 -0
- package/skill/references/onboarding/modules/scripts/upload_screenshots.sh +34 -20
- package/skill/references/onboarding/modules/service-registration.md +20 -317
- package/skill/references/runtime-entry.md +63 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -u
|
|
4
|
+
|
|
5
|
+
MODE="${1:-}"
|
|
6
|
+
PRODUCT_TYPE=""
|
|
7
|
+
PROJECT_PATH=""
|
|
8
|
+
PROJECT_SELECTION=""
|
|
9
|
+
|
|
10
|
+
prepare_new_project() {
|
|
11
|
+
local project_path="$1"
|
|
12
|
+
case "$project_path" in /*) ;; *) echo "ROUTE_INSPECT_ERROR:projectPath 必须是绝对路径" >&2; exit 2 ;; esac
|
|
13
|
+
if [ -L "$project_path" ] || { [ -e "$project_path" ] && { [ ! -d "$project_path" ] || [ -n "$(find "$project_path" -mindepth 1 -maxdepth 1 -print -quit 2>/dev/null)" ]; }; }; then
|
|
14
|
+
echo "ROUTE_INSPECT_ERROR:NEW_PROJECT 路径必须尚不存在或为空且不能是符号链接" >&2
|
|
15
|
+
exit 2
|
|
16
|
+
fi
|
|
17
|
+
jq -n '{projectSelection:"NEW_PROJECT",projectOrigin:"NEW_PROJECT",projectOriginLabel:"本轮新建项目",preparationStatus:"READY"}'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
case "$MODE" in
|
|
21
|
+
prepare-new)
|
|
22
|
+
[ "$#" -eq 2 ] || { echo "ROUTE_INSPECT_ERROR:用法 project_route_inspector.sh prepare-new <projectPath>" >&2; exit 2; }
|
|
23
|
+
prepare_new_project "$2"
|
|
24
|
+
exit 0
|
|
25
|
+
;;
|
|
26
|
+
scan)
|
|
27
|
+
[ "$#" -eq 4 ] || { echo "ROUTE_INSPECT_ERROR:用法 project_route_inspector.sh scan <productType> <projectPath> <projectSelection>" >&2; exit 2; }
|
|
28
|
+
PRODUCT_TYPE="$2"
|
|
29
|
+
PROJECT_PATH="$3"
|
|
30
|
+
PROJECT_SELECTION="$4"
|
|
31
|
+
;;
|
|
32
|
+
*)
|
|
33
|
+
echo "ROUTE_INSPECT_ERROR:用法 project_route_inspector.sh prepare-new <projectPath> 或 scan <productType> <projectPath> <projectSelection>" >&2
|
|
34
|
+
exit 2
|
|
35
|
+
;;
|
|
36
|
+
esac
|
|
37
|
+
|
|
38
|
+
case "$PRODUCT_TYPE" in aipay|webpay|apppay) ;; *) echo "ROUTE_INSPECT_ERROR:productType 非法" >&2; exit 2 ;; esac
|
|
39
|
+
case "$PROJECT_SELECTION" in CURRENT_PROJECT|OTHER_PROJECT|PREPARED_NEW_PROJECT) ;; *) echo "ROUTE_INSPECT_ERROR:projectSelection 非法" >&2; exit 2 ;; esac
|
|
40
|
+
case "$PROJECT_PATH" in /*) ;; *) echo "ROUTE_INSPECT_ERROR:projectPath 必须是绝对路径" >&2; exit 2 ;; esac
|
|
41
|
+
|
|
42
|
+
[ -d "$PROJECT_PATH" ] && [ -r "$PROJECT_PATH" ] || { echo "ROUTE_INSPECT_ERROR:项目路径不可访问" >&2; exit 2; }
|
|
43
|
+
|
|
44
|
+
if [ "$PROJECT_SELECTION" = "PREPARED_NEW_PROJECT" ]; then
|
|
45
|
+
PROJECT_ORIGIN="NEW_PROJECT"
|
|
46
|
+
PROJECT_ORIGIN_LABEL="本轮新建项目"
|
|
47
|
+
else
|
|
48
|
+
PROJECT_ORIGIN="EXISTING_PROJECT"
|
|
49
|
+
PROJECT_ORIGIN_LABEL="现有项目"
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
scan() {
|
|
53
|
+
local pattern="$1"
|
|
54
|
+
local file
|
|
55
|
+
while IFS= read -r -d '' file; do
|
|
56
|
+
if grep -En "$pattern" "$file" 2>/dev/null | grep -Ev '^[0-9]+:[[:space:]]*(//|#|\*|<!--)' | head -n 1 | grep -q .; then
|
|
57
|
+
printf '%s\n' "$file"
|
|
58
|
+
return 0
|
|
59
|
+
fi
|
|
60
|
+
done < <(find "$PROJECT_PATH" -type d \( \
|
|
61
|
+
-name .git -o -name .hg -o -name .svn -o -name .cache -o -name .gradle -o -name .idea -o \
|
|
62
|
+
-name .next -o -name .nuxt -o -name .pytest_cache -o -name .tox -o -name .Trash -o -name .venv -o \
|
|
63
|
+
-name Library -o -name __pycache__ -o -name build -o -name coverage -o -name dist -o -name node_modules -o -name target -o -name vendor \
|
|
64
|
+
\) -prune -o -type f \( -name '*.java' -o -name '*.kt' -o -name '*.js' -o -name '*.mjs' -o -name '*.cjs' -o -name '*.ts' -o -name '*.tsx' -o -name '*.py' -o -name '*.php' -o -name '*.cs' \) -print0)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
webpay_marker='alipay\.trade\.page\.pay|AlipayTradePagePay(Request|Model|Response)'
|
|
68
|
+
apppay_marker='alipay\.trade\.app\.pay|AlipayTradeAppPay(Request|Model|Response)'
|
|
69
|
+
trade_query_marker='alipay\.trade\.query|AlipayTradeQuery(Request|Model|Response)|alipay_trade_query_response'
|
|
70
|
+
trade_refund_marker='alipay\.trade\.refund|AlipayTradeRefund(Request|Model|Response)|alipay_trade_refund_response'
|
|
71
|
+
trade_refund_query_marker='alipay\.trade\.fastpay\.refund\.query|AlipayTradeFastpayRefundQuery(Request|Model|Response)|alipay_trade_fastpay_refund_query_response'
|
|
72
|
+
trade_close_marker='alipay\.trade\.close|AlipayTradeClose(Request|Model|Response)|alipay_trade_close_response'
|
|
73
|
+
trade_notify_marker='notify_url|notifyUrl|NotifyUrl|setNotifyUrl|异步通知'
|
|
74
|
+
aipay_payment_needed_marker='Payment-Needed'
|
|
75
|
+
aipay_payment_proof_marker='Payment-Proof'
|
|
76
|
+
aipay_payment_validation_marker='Payment-Validation'
|
|
77
|
+
aipay_payment_verify_marker='alipay\.aipay\.agent\.payment\.verify|AlipayAipayAgentPaymentVerify(Request|Model|Response)|alipay_aipay_agent_payment_verify_response'
|
|
78
|
+
aipay_fulfillment_confirm_marker='alipay\.aipay\.agent\.fulfillment\.confirm|AlipayAipayAgentFulfillmentConfirm(Request|Model|Response)|alipay_aipay_agent_fulfillment_confirm_response'
|
|
79
|
+
aipay_marker="$aipay_payment_needed_marker|$aipay_payment_proof_marker|$aipay_payment_verify_marker|$aipay_fulfillment_confirm_marker"
|
|
80
|
+
|
|
81
|
+
target_marker=""
|
|
82
|
+
other_products=""
|
|
83
|
+
case "$PRODUCT_TYPE" in
|
|
84
|
+
aipay) target_marker="$aipay_marker" ;;
|
|
85
|
+
webpay) target_marker="$webpay_marker" ;;
|
|
86
|
+
apppay) target_marker="$apppay_marker" ;;
|
|
87
|
+
esac
|
|
88
|
+
|
|
89
|
+
[ -z "$(scan "$webpay_marker")" ] || [ "$PRODUCT_TYPE" = "webpay" ] || other_products="${other_products}AI 网页应用收款,"
|
|
90
|
+
[ -z "$(scan "$apppay_marker")" ] || [ "$PRODUCT_TYPE" = "apppay" ] || other_products="${other_products}AI 移动应用收款,"
|
|
91
|
+
[ -z "$(scan "$aipay_marker")" ] || [ "$PRODUCT_TYPE" = "aipay" ] || other_products="${other_products}AI 按量付费,"
|
|
92
|
+
other_products="${other_products%,}"
|
|
93
|
+
[ -n "$other_products" ] || other_products="无"
|
|
94
|
+
|
|
95
|
+
if [ -z "$(scan "$target_marker")" ]; then
|
|
96
|
+
if [ "$other_products" = "无" ]; then
|
|
97
|
+
status="NO_PAYMENT"
|
|
98
|
+
if [ "$PROJECT_SELECTION" = "PREPARED_NEW_PROJECT" ]; then
|
|
99
|
+
evidence="固定检查器扫描本轮已初始化的新项目,未发现目标产品或其他受支持支付代码"
|
|
100
|
+
else
|
|
101
|
+
evidence="固定检查器未发现目标产品或其他受支持支付代码"
|
|
102
|
+
fi
|
|
103
|
+
else status="OTHER_PRODUCT_ONLY"; evidence="固定检查器只发现其他受支持支付产品代码"; fi
|
|
104
|
+
else
|
|
105
|
+
if [ "$PRODUCT_TYPE" = "aipay" ]; then
|
|
106
|
+
required_patterns=("$aipay_payment_needed_marker" "$aipay_payment_proof_marker" "$aipay_payment_verify_marker" "$aipay_fulfillment_confirm_marker" "$aipay_payment_validation_marker")
|
|
107
|
+
elif [ "$PRODUCT_TYPE" = "webpay" ]; then
|
|
108
|
+
required_patterns=("$webpay_marker" "$trade_query_marker" "$trade_refund_marker" "$trade_refund_query_marker" "$trade_close_marker" "$trade_notify_marker")
|
|
109
|
+
else
|
|
110
|
+
required_patterns=("$apppay_marker" "$trade_query_marker" "$trade_refund_marker" "$trade_refund_query_marker" "$trade_close_marker" "$trade_notify_marker")
|
|
111
|
+
fi
|
|
112
|
+
missing=()
|
|
113
|
+
for pattern in "${required_patterns[@]}"; do
|
|
114
|
+
[ -n "$(scan "$pattern")" ] || missing+=("$pattern")
|
|
115
|
+
done
|
|
116
|
+
if [ "${#missing[@]}" -eq 0 ]; then
|
|
117
|
+
status="TARGET_PARTIAL"
|
|
118
|
+
evidence="固定检查器逐项发现目标产品入口及全部核心接口标记,但静态扫描不能证明配置、安全、测试和 checklist 完成;必须进入 Integration 验证分支"
|
|
119
|
+
else
|
|
120
|
+
status="TARGET_PARTIAL"
|
|
121
|
+
evidence="固定检查器发现目标产品代码,但至少一个核心接口标记缺失;不得按完整集成路由"
|
|
122
|
+
fi
|
|
123
|
+
fi
|
|
124
|
+
|
|
125
|
+
jq -n \
|
|
126
|
+
--arg selection "$PROJECT_SELECTION" \
|
|
127
|
+
--arg origin "$PROJECT_ORIGIN" \
|
|
128
|
+
--arg originLabel "$PROJECT_ORIGIN_LABEL" \
|
|
129
|
+
--arg status "$status" \
|
|
130
|
+
--arg evidence "$evidence" \
|
|
131
|
+
--arg others "$other_products" \
|
|
132
|
+
'{projectSelection:$selection,projectOrigin:$origin,projectOriginLabel:$originLabel,integrationStatus:$status,evidence:$evidence,otherProducts:$others}'
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import process from 'node:process';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
|
|
9
|
+
import { isWindowsPlatform } from './platform_compat.mjs';
|
|
10
|
+
|
|
11
|
+
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const allowedScript = path.resolve(scriptDir, '../../integration/modules/scripts/local_402_sandbox_pay.py');
|
|
13
|
+
|
|
14
|
+
function commandRuns(command, args) {
|
|
15
|
+
const result = spawnSync(command, args, { stdio: 'ignore', shell: false });
|
|
16
|
+
return result.status === 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function resolvePython() {
|
|
20
|
+
const candidates = isWindowsPlatform()
|
|
21
|
+
? [
|
|
22
|
+
{ command: 'py', prefix: ['-3'] },
|
|
23
|
+
{ command: 'python', prefix: [] },
|
|
24
|
+
{ command: 'python3', prefix: [] }
|
|
25
|
+
]
|
|
26
|
+
: [
|
|
27
|
+
{ command: 'python3', prefix: [] },
|
|
28
|
+
{ command: 'python', prefix: [] }
|
|
29
|
+
];
|
|
30
|
+
return candidates.find(({ command, prefix }) => commandRuns(command, [...prefix, '--version'])) || null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function main() {
|
|
34
|
+
const scriptInput = process.argv[2];
|
|
35
|
+
if (!scriptInput) throw new Error('缺少 Python 脚本路径');
|
|
36
|
+
const resolvedScript = path.resolve(scriptInput);
|
|
37
|
+
if (resolvedScript !== allowedScript || !fs.existsSync(resolvedScript) || fs.lstatSync(resolvedScript).isSymbolicLink()) {
|
|
38
|
+
throw new Error('只允许执行 Skill 内置的 AI 按量付费沙箱测试脚本');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const python = resolvePython();
|
|
42
|
+
if (!python) throw new Error('未找到可用的 Python 3 运行时');
|
|
43
|
+
const result = spawnSync(python.command, [...python.prefix, resolvedScript, ...process.argv.slice(3)], {
|
|
44
|
+
stdio: 'inherit',
|
|
45
|
+
shell: false
|
|
46
|
+
});
|
|
47
|
+
if (result.error) throw result.error;
|
|
48
|
+
process.exitCode = Number.isInteger(result.status) ? result.status : 1;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
main();
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error(`PYTHON_RUNNER_ERROR:${error.message}`);
|
|
55
|
+
process.exitCode = 1;
|
|
56
|
+
}
|