@xiashe/cli 0.1.33 → 0.1.34
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 +1 -1
- package/bin/xiashe.mjs +46 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -57,4 +57,4 @@ Production defaults:
|
|
|
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.34 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, ordinary hosts inject `XIASHE_HOST_BUSINESS_SESSION` only into the supplied payment command’s foreground child process. Codex Node REPL uses the private MCP response’s stdin-only adapter because its spawned child does not inherit request metadata. 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
|
@@ -57,6 +57,8 @@ const PRODUCT_ENV = COMMAND_NAME === 'agentpie' ? 'global' : 'cn';
|
|
|
57
57
|
// local state, stdout, or a model-visible command argument.
|
|
58
58
|
const PAYMENT_HOST_CONTRACT_VERSION = 'xiashe.payment-host.v1';
|
|
59
59
|
const PAYMENT_HOST_SESSION_ENV = 'XIASHE_HOST_BUSINESS_SESSION';
|
|
60
|
+
const PAYMENT_HOST_STDIN_FLAG = 'host-session-stdin';
|
|
61
|
+
const PAYMENT_HOST_STDIN_MAX_BYTES = 256;
|
|
60
62
|
// These are compatibility adapters for known OpenAI/Codex hosts while their
|
|
61
63
|
// runtimes adopt the portable environment contract. Unknown host variables
|
|
62
64
|
// are deliberately not guessed: other Agents must inject the standard name.
|
|
@@ -278,13 +280,51 @@ function hostSessionContractStatus(resolution = null) {
|
|
|
278
280
|
};
|
|
279
281
|
}
|
|
280
282
|
|
|
281
|
-
function
|
|
283
|
+
async function readPaymentBusinessSessionFromStdin() {
|
|
284
|
+
return await new Promise((resolve) => {
|
|
285
|
+
let received = '';
|
|
286
|
+
let settled = false;
|
|
287
|
+
const finish = (value = null) => {
|
|
288
|
+
if (settled) return;
|
|
289
|
+
settled = true;
|
|
290
|
+
clearTimeout(timeout);
|
|
291
|
+
process.stdin.pause();
|
|
292
|
+
resolve(value);
|
|
293
|
+
};
|
|
294
|
+
const timeout = setTimeout(() => finish(null), 5_000);
|
|
295
|
+
process.stdin.setEncoding('utf8');
|
|
296
|
+
process.stdin.on('data', (chunk) => {
|
|
297
|
+
received += chunk;
|
|
298
|
+
if (Buffer.byteLength(received, 'utf8') > PAYMENT_HOST_STDIN_MAX_BYTES) {
|
|
299
|
+
finish(null);
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
process.stdin.once('end', () => finish(received.trim()));
|
|
303
|
+
process.stdin.once('error', () => finish(null));
|
|
304
|
+
process.stdin.resume();
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
async function resolvePaymentBusinessSession(flags) {
|
|
282
309
|
// A model-visible command-line session is not an acceptable trust boundary.
|
|
283
310
|
// Hosts that cannot inject the standard environment must implement the v1
|
|
284
311
|
// adapter rather than asking a user or model to provide a replacement.
|
|
285
312
|
if (flags['session-id'] !== undefined || flags.sessionId !== undefined) {
|
|
286
313
|
return { error: 'host_session_override_forbidden' };
|
|
287
314
|
}
|
|
315
|
+
if (flags[PAYMENT_HOST_STDIN_FLAG] !== undefined) {
|
|
316
|
+
if (flags[PAYMENT_HOST_STDIN_FLAG] !== true) {
|
|
317
|
+
return { error: 'host_session_override_forbidden' };
|
|
318
|
+
}
|
|
319
|
+
const candidate = await readPaymentBusinessSessionFromStdin();
|
|
320
|
+
if (HOST_BUSINESS_SESSION_PATTERN.test(String(candidate || '').trim())) {
|
|
321
|
+
return {
|
|
322
|
+
sessionId: String(candidate).trim(),
|
|
323
|
+
provider: 'codex_node_repl_request_metadata'
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
288
328
|
const standardCandidate = String(process.env[PAYMENT_HOST_SESSION_ENV] || '').trim();
|
|
289
329
|
if (HOST_BUSINESS_SESSION_PATTERN.test(standardCandidate)) {
|
|
290
330
|
return {
|
|
@@ -320,8 +360,8 @@ function hostBusinessSessionUnavailableResult() {
|
|
|
320
360
|
};
|
|
321
361
|
}
|
|
322
362
|
|
|
323
|
-
function hostBusinessSessionOverrideForbiddenResult() {
|
|
324
|
-
const hostResolution = resolvePaymentBusinessSession({});
|
|
363
|
+
async function hostBusinessSessionOverrideForbiddenResult() {
|
|
364
|
+
const hostResolution = await resolvePaymentBusinessSession({});
|
|
325
365
|
return {
|
|
326
366
|
ok: false,
|
|
327
367
|
status: 'host_session_override_forbidden',
|
|
@@ -1270,7 +1310,7 @@ async function cmdPayment(sub, args, global) {
|
|
|
1270
1310
|
const flags = parseFlags(args);
|
|
1271
1311
|
if (sub === 'bridge-info' || sub === 'bridge' || sub === 'prepare') {
|
|
1272
1312
|
const result = await getAlipayWalletBridgeInfo({ timeoutMs: global.timeoutMs });
|
|
1273
|
-
const businessSession = resolvePaymentBusinessSession({});
|
|
1313
|
+
const businessSession = await resolvePaymentBusinessSession({});
|
|
1274
1314
|
print({
|
|
1275
1315
|
...result,
|
|
1276
1316
|
hostSessionContract: hostSessionContractStatus(businessSession?.error ? null : businessSession)
|
|
@@ -1298,9 +1338,9 @@ async function cmdPayment(sub, args, global) {
|
|
|
1298
1338
|
if (sub === 'pay') {
|
|
1299
1339
|
const resourceUrl = requireArg(flags['resource-url'] || flags.resourceUrl || flags.r, '--resource-url');
|
|
1300
1340
|
const intentSummary = requireArg(flags['intent-summary'] || flags.intentSummary || flags.i, '--intent-summary');
|
|
1301
|
-
const businessSession = resolvePaymentBusinessSession(flags);
|
|
1341
|
+
const businessSession = await resolvePaymentBusinessSession(flags);
|
|
1302
1342
|
if (businessSession?.error === 'host_session_override_forbidden') {
|
|
1303
|
-
print(hostBusinessSessionOverrideForbiddenResult(), global);
|
|
1343
|
+
print(await hostBusinessSessionOverrideForbiddenResult(), global);
|
|
1304
1344
|
process.exitCode = EXIT_RUNTIME;
|
|
1305
1345
|
return;
|
|
1306
1346
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiashe/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
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.34"
|
|
14
14
|
},
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">=20"
|