@xiashe/cli 0.1.31 → 0.1.32
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 +3 -3
- package/bin/xiashe.mjs +72 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ xiashe skills publish submit "<submission-id>"
|
|
|
26
26
|
# This checks only that the bridge CLI is present; it does not query a wallet.
|
|
27
27
|
xiashe payment bridge-info
|
|
28
28
|
# After the Agent shows the Skill and purpose and the user explicitly agrees:
|
|
29
|
-
xiashe payment pay --resource-url "https://<payment-resource-site>/payment/alipay-ai-collect/skills/<skillCatalogId>?orderId=<id>" --intent-summary "使用付费 Skill:<name>" --
|
|
29
|
+
xiashe payment pay --resource-url "https://<payment-resource-site>/payment/alipay-ai-collect/skills/<skillCatalogId>?orderId=<id>" --intent-summary "使用付费 Skill:<name>" --confirm
|
|
30
30
|
xiashe payment status --resource-url "https://<payment-resource-site>/payment/alipay-ai-collect/skills/<skillCatalogId>?orderId=<id>"
|
|
31
31
|
# Only for an Alipay support-assisted read-only query. This is not out_trade_no or Payment-Proof.
|
|
32
32
|
xiashe payment status --resource-url "https://<payment-resource-site>/payment/alipay-ai-collect/skills/<skillCatalogId>?orderId=<id>" --business-no "<32-digit outShakeNo with 8282 in positions 11–14>"
|
|
@@ -51,10 +51,10 @@ Production defaults:
|
|
|
51
51
|
`xiashe payment` is the shell-capable Agent path for Alipay AI Pay. It delegates only to the official local `alipay-bot` supplied by `@alipay/agent-payment`; it does not implement or expose `Payment-Needed` / `Payment-Proof` itself.
|
|
52
52
|
|
|
53
53
|
- `xiashe payment bridge-info` checks that the official buyer CLI can run and exposes the buyer-pay/status command contract required by the bridge. It does not check wallet authorization, merchant activation, or whether a transaction can be created. `payment doctor` remains a manual wallet-status diagnostic only.
|
|
54
|
-
- `xiashe payment pay` requests the resource once, saves its exact 402 request in a private local file, and passes that file plus the current Agent business-session ID to the official buyer CLI. It requires an HTTPS AI-Collect resource URL, a visible purchase-purpose summary, `--session-id
|
|
54
|
+
- `xiashe payment pay` requests the resource once, saves its exact 402 request in a private local file, and passes that file plus the current Agent business-session ID to the official buyer CLI. It requires an HTTPS AI-Collect resource URL, a visible purchase-purpose summary, and `--confirm`. After confirmation it resolves a valid current host session only from its own local process; `--session-id` remains an optional explicit adapter override. It never generates, prints, or persists a replacement session ID. If no valid host session is available, it returns `host_session_unavailable` and does not invoke the wallet.
|
|
55
55
|
- `xiashe payment status` resumes the same local attempt with its official query credential and returns a normalized status only. If Alipay support provides the documented 32-digit `outShakeNo` (with `8282` in positions 11–14, sometimes called a business order number), use `--out-shake-no` or `--business-no` for one read-only status query; it is validated, never stored, and cannot create a payment or acknowledge fulfillment. No wallet protocol payload or proof is printed. A QR or confirmation image is exposed only as `officialMedia` when the official wallet emitted that image in the same invocation; the bridge never generates one itself.
|
|
56
56
|
- `xiashe payment preflight` requests the seller resource once and validates the public field shape of its 402 bill without opening a wallet or creating a trade. It does not prove that Alipay accepts the seller signature, service binding, or merchant activation. `xiashe payment diagnose` is read-only. It reports the last stored safe diagnosis for that local attempt, including allow-listed official error/sub-codes, message, and request/trace identifiers when present, without contacting Alipay, replaying the resource, or exposing its local query credential.
|
|
57
57
|
|
|
58
58
|
An Agent must never add `--confirm` before the user has explicitly agreed to the displayed purpose. If the wallet is unavailable, obtain permission before running the official `@alipay/agent-payment` setup, then run `payment doctor` again.
|
|
59
59
|
|
|
60
|
-
For a clean Codex Task, the XiaShe MCP response provides a version-pinned ephemeral command such as `npx -y @xiashe/cli@0.1.
|
|
60
|
+
For a clean Codex Task, the XiaShe MCP response provides a version-pinned ephemeral command such as `npx -y @xiashe/cli@0.1.32 payment bridge-info`. No global `xiashe` installation is required for that path. Do not run preflight before requesting payment confirmation: it is a read-only diagnostic only. After explicit confirmation, run the supplied payment and status commands exactly as supplied in the foreground. The Agent must inspect bridge JSON instead of suppressing output or guessing status from shell text. Failed attempts include a redacted `diagnosis` object and `userVisible` next step; do not replace them with a generic payment-failed message.
|
package/bin/xiashe.mjs
CHANGED
|
@@ -51,6 +51,20 @@ const EXIT_RUNTIME = 5;
|
|
|
51
51
|
const COMMAND_NAME = process.env.XIASHE_CLI_NAME || 'xiashe';
|
|
52
52
|
const PRODUCT_NAME = process.env.XIASHE_PRODUCT_NAME || (COMMAND_NAME === 'agentpie' ? 'AgentPie' : 'XiaShe');
|
|
53
53
|
const PRODUCT_ENV = COMMAND_NAME === 'agentpie' ? 'global' : 'cn';
|
|
54
|
+
// A payment business session is host-owned. Keep the allowlist deliberately
|
|
55
|
+
// narrow: this CLI may consume a current Task/session identifier from its own
|
|
56
|
+
// process, but it must never manufacture, print, or persist one.
|
|
57
|
+
const HOST_BUSINESS_SESSION_ENV_NAMES = Object.freeze([
|
|
58
|
+
'XIASHE_HOST_BUSINESS_SESSION',
|
|
59
|
+
'AGENT_HOST_BUSINESS_SESSION',
|
|
60
|
+
'AGENT_SESSION_ID',
|
|
61
|
+
'CODEX_THREAD_ID',
|
|
62
|
+
'OPENAI_THREAD_ID',
|
|
63
|
+
'AGENT_THREAD_ID',
|
|
64
|
+
'THREAD_ID',
|
|
65
|
+
'CONVERSATION_ID'
|
|
66
|
+
]);
|
|
67
|
+
const HOST_BUSINESS_SESSION_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{7,191}$/;
|
|
54
68
|
|
|
55
69
|
function usage() {
|
|
56
70
|
const c = COMMAND_NAME;
|
|
@@ -103,7 +117,7 @@ Usage:
|
|
|
103
117
|
|
|
104
118
|
${c} payment bridge-info|doctor
|
|
105
119
|
${c} payment preflight --resource-url <https-url>
|
|
106
|
-
${c} payment pay --resource-url <https-url> --intent-summary <text> --session-id <active-agent-session> --confirm [--wallet-timeout-ms <ms>]
|
|
120
|
+
${c} payment pay --resource-url <https-url> --intent-summary <text> [--session-id <active-agent-session>] --confirm [--wallet-timeout-ms <ms>]
|
|
107
121
|
${c} payment status --resource-url <https-url> [--out-shake-no <32-digit-8282>|--business-no <32-digit-8282>]
|
|
108
122
|
${c} payment diagnose --resource-url <https-url>
|
|
109
123
|
${c} payment support-report --resource-url <https-url>
|
|
@@ -251,6 +265,47 @@ function requireArg(value, label) {
|
|
|
251
265
|
return value;
|
|
252
266
|
}
|
|
253
267
|
|
|
268
|
+
function resolvePaymentBusinessSession(flags) {
|
|
269
|
+
const explicitValue = flags['session-id'] ?? flags.sessionId;
|
|
270
|
+
if (explicitValue !== undefined) {
|
|
271
|
+
if (explicitValue === true || !String(explicitValue).trim()) {
|
|
272
|
+
fail('Missing value for --session-id.', EXIT_USAGE);
|
|
273
|
+
}
|
|
274
|
+
// Preserve the official SDK's validation and error reporting for an
|
|
275
|
+
// explicit caller-provided value. This is still useful for compatible
|
|
276
|
+
// hosts that expose a session through their own runtime adapter.
|
|
277
|
+
return {
|
|
278
|
+
sessionId: String(explicitValue).trim(),
|
|
279
|
+
source: 'explicit_argument'
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
for (const environmentName of HOST_BUSINESS_SESSION_ENV_NAMES) {
|
|
283
|
+
const candidate = String(process.env[environmentName] || '').trim();
|
|
284
|
+
if (HOST_BUSINESS_SESSION_PATTERN.test(candidate)) {
|
|
285
|
+
return {
|
|
286
|
+
sessionId: candidate,
|
|
287
|
+
source: 'current_host_environment'
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function hostBusinessSessionUnavailableResult() {
|
|
295
|
+
return {
|
|
296
|
+
ok: false,
|
|
297
|
+
status: 'host_session_unavailable',
|
|
298
|
+
failureCode: 'HOST_BUSINESS_SESSION_UNAVAILABLE',
|
|
299
|
+
walletInvoked: false,
|
|
300
|
+
diagnosis: {
|
|
301
|
+
code: 'host_business_session_unavailable',
|
|
302
|
+
stage: 'host_session_resolution'
|
|
303
|
+
},
|
|
304
|
+
userVisible: '当前 Agent 未提供可用的任务会话标识,尚未发起支付宝付款。',
|
|
305
|
+
nextStep: '请在能向本地付款 CLI 提供当前任务 sessionId、threadId 或 conversationId 的 Agent 环境中重试;不要手工创建或粘贴替代值。'
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
|
|
254
309
|
function publicError(error) {
|
|
255
310
|
const message = error instanceof Error ? error.message : String(error || '');
|
|
256
311
|
const code = error?.code || message.match(/\b[A-Z][A-Z0-9_]{4,}\b/)?.[0] || '';
|
|
@@ -1208,14 +1263,27 @@ async function cmdPayment(sub, args, global) {
|
|
|
1208
1263
|
if (sub === 'pay') {
|
|
1209
1264
|
const resourceUrl = requireArg(flags['resource-url'] || flags.resourceUrl || flags.r, '--resource-url');
|
|
1210
1265
|
const intentSummary = requireArg(flags['intent-summary'] || flags.intentSummary || flags.i, '--intent-summary');
|
|
1211
|
-
const
|
|
1266
|
+
const businessSession = resolvePaymentBusinessSession(flags);
|
|
1267
|
+
if (!businessSession) {
|
|
1268
|
+
print(hostBusinessSessionUnavailableResult(), global);
|
|
1269
|
+
process.exitCode = EXIT_RUNTIME;
|
|
1270
|
+
return;
|
|
1271
|
+
}
|
|
1212
1272
|
const result = await payAlipay402Resource({
|
|
1213
1273
|
resourceUrl,
|
|
1214
1274
|
intentSummary,
|
|
1215
|
-
sessionId,
|
|
1275
|
+
sessionId: businessSession.sessionId,
|
|
1216
1276
|
confirm: flags.confirm === true
|
|
1217
1277
|
}, walletTimeoutMs ? { timeoutMs: walletTimeoutMs } : {});
|
|
1218
|
-
print(
|
|
1278
|
+
print({
|
|
1279
|
+
...result,
|
|
1280
|
+
// This confirms resolution occurred without exposing the identifier or
|
|
1281
|
+
// the environment variable that contained it.
|
|
1282
|
+
hostBusinessSession: {
|
|
1283
|
+
resolved: true,
|
|
1284
|
+
source: businessSession.source
|
|
1285
|
+
}
|
|
1286
|
+
}, global);
|
|
1219
1287
|
return;
|
|
1220
1288
|
}
|
|
1221
1289
|
if (sub === 'status') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiashe/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"xiashe": "bin/xiashe.mjs"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"README.md"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xiashe/sdk": "0.1.
|
|
13
|
+
"@xiashe/sdk": "0.1.32"
|
|
14
14
|
},
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">=20"
|